Updated to 68.0

This commit is contained in:
Martin Stransky 2019-07-02 12:23:46 +02:00
parent 25b842803d
commit ec241d8209
16 changed files with 19 additions and 4736 deletions

2
.gitignore vendored
View File

@ -351,3 +351,5 @@ firefox-3.6.4.source.tar.bz2
/firefox-67.0.3.source.tar.xz
/firefox-67.0.4.source.tar.xz
/firefox-langpacks-67.0.4-20190620.tar.xz
/firefox-68.0.source.tar.xz
/firefox-langpacks-68.0-20190702.tar.xz

View File

@ -17,49 +17,6 @@ diff -up firefox-66.0/config/system-headers.mozbuild.firefox-pipewire firefox-66
'pixman.h',
'pk11func.h',
'pk11pqg.h',
diff -up firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/app_capturer_linux.cc.firefox-pipewire firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/app_capturer_linux.cc
--- firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/app_capturer_linux.cc.firefox-pipewire 2019-03-12 15:27:37.675285710 +0100
+++ firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/app_capturer_linux.cc 2019-03-12 15:27:37.675285710 +0100
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "modules/desktop_capture/desktop_capture_options.h"
+#include "modules/desktop_capture/desktop_capturer.h"
+
+#if defined(USE_X11)
+#include "modules/desktop_capture/app_capturer_x11.h"
+#endif // defined(USE_X11)
+
+namespace webrtc {
+
+// static
+AppCapturer* AppCapturer::Create(const DesktopCaptureOptions& options) {
+#if defined(USE_X11)
+ return AppCapturerX11::Create(options);
+#endif // defined(USE_X11)
+
+ return nullptr;
+}
+
+// static
+std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawAppCapturer(
+ const DesktopCaptureOptions& options) {
+#if defined(USE_X11)
+ return AppCapturerX11::CreateRawAppCapturer(options);
+#endif // defined(USE_X11)
+
+ return nullptr;
+}
+
+} // namespace webrtc
diff -up firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/app_capturer_x11.cc.firefox-pipewire firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/app_capturer_x11.cc
--- firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/app_capturer_x11.cc.firefox-pipewire 2019-03-12 01:22:20.000000000 +0100
+++ firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/app_capturer_x11.cc 2019-03-12 15:27:37.675285710 +0100

View File

@ -76,15 +76,8 @@ ExcludeArch: s390x
%bcond_without langpacks
# Disable crashreporter as we want to collect Wayland crashes.
%global enable_mozilla_crashreporter 0
%if !%{debug_build}
%ifarch %{ix86} x86_64
# Disable crashreporter sa we want to collect Wayland crashes.
%if 0%{?fedora} < 28
%global enable_mozilla_crashreporter 1
%endif
%endif
%endif
%if !%{release_build}
%global pre_tag .test
@ -92,13 +85,13 @@ ExcludeArch: s390x
Summary: Mozilla Firefox Web browser
Name: firefox
Version: 67.0.4
Version: 68.0
Release: 1%{?pre_tag}%{?dist}
URL: https://www.mozilla.org/firefox/
License: MPLv1.1 or GPLv2+ or LGPLv2+
Source0: https://archive.mozilla.org/pub/firefox/releases/%{version}%{?pre_version}/source/firefox-%{version}%{?pre_version}.source.tar.xz
%if %{with langpacks}
Source1: firefox-langpacks-%{version}%{?pre_version}-20190620.tar.xz
Source1: firefox-langpacks-%{version}%{?pre_version}-20190702.tar.xz
%endif
Source2: cbindgen-vendor.tar.xz
Source10: firefox-mozconfig
@ -142,23 +135,12 @@ Patch227: firefox-locale-debug.patch
# Upstream patches
Patch402: mozilla-1196777.patch
Patch412: mozilla-1337988.patch
Patch413: mozilla-1353817.patch
#Patch413: mozilla-1353817.patch
Patch415: Bug-1238661---fix-mozillaSignalTrampoline-to-work-.patch
Patch417: bug1375074-save-restore-x28.patch
Patch418: mozilla-1526243.patch
Patch419: mozilla-1540145.patch
# Wayland specific upstream patches
Patch574: firefox-pipewire.patch
Patch575: mozilla-1423598-popup.patch
Patch576: mozilla-1532643-popup.patch
Patch577: mozilla-1535567.patch
Patch579: mozilla-1468911.patch
Patch580: mozilla-1539471.patch
Patch581: mozilla-1517205.patch
Patch582: mozilla-1508378.patch
Patch583: mozilla-1467127.patch
Patch584: mozilla-1552590.patch
#Patch574: firefox-pipewire.patch
# PGO/LTO patches
Patch600: pgo.patch
@ -204,9 +186,7 @@ BuildRequires: clang-libs
%if 0%{?build_with_clang}
BuildRequires: lld
%endif
%if 0%{?fedora} > 28
BuildRequires: pipewire-devel
%endif
%if !0%{?use_bundled_cbindgen}
BuildRequires: cbindgen
%endif
@ -351,7 +331,7 @@ This package contains results of tests executed during build.
%patch227 -p1 -b .locale-debug
%patch402 -p1 -b .1196777
%patch413 -p1 -b .1353817
#%patch413 -p1 -b .1353817
%ifarch %{arm}
%patch415 -p1 -b .1238661
%endif
@ -359,22 +339,9 @@ This package contains results of tests executed during build.
%if 0%{?big_endian}
%patch26 -p1 -b .icu
%endif
%patch418 -p1 -b .mozilla-1526243
%patch419 -p1 -b .mozilla-1540145
# Wayland specific upstream patches
%if 0%{?fedora} > 28
%patch574 -p1 -b .firefox-pipewire
%endif
%patch575 -p1 -b .mozilla-1423598-popup
%patch576 -p1 -b .mozilla-1532643-popup
%patch577 -p1 -b .mozilla-1535567
%patch579 -p1 -b .mozilla-1468911
%patch580 -p1 -b .mozilla-1539471
%patch581 -p1 -b .mozilla-1517205
%patch582 -p1 -b .mozilla-1508378
#%patch583 -p1 -b .mozilla-1467127
#%patch584 -p1 -b .mozilla-1552590
#%patch574 -p1 -b .firefox-pipewire
# PGO patches
%patch600 -p1 -b .pgo
@ -944,6 +911,9 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
#---------------------------------------------------------------------
%changelog
* Tue Jul 2 2019 Martin Stransky <stransky@redhat.com> - 68.0-1
- Updated to 68.0
* Thu Jun 20 2019 Martin Stransky <stransky@redhat.com> - 67.0.4-1
- Updated to 67.0.4

View File

@ -1,6 +1,6 @@
diff -up firefox-65.0/widget/gtk/nsWindow.cpp.1196777 firefox-65.0/widget/gtk/nsWindow.cpp
--- firefox-65.0/widget/gtk/nsWindow.cpp.1196777 2019-01-28 14:37:27.470163867 +0100
+++ firefox-65.0/widget/gtk/nsWindow.cpp 2019-01-28 14:41:52.479064393 +0100
diff -up firefox-68.0/widget/gtk/nsWindow.cpp.1196777 firefox-68.0/widget/gtk/nsWindow.cpp
--- firefox-68.0/widget/gtk/nsWindow.cpp.1196777 2019-07-02 11:47:06.864726826 +0200
+++ firefox-68.0/widget/gtk/nsWindow.cpp 2019-07-02 11:48:09.896544339 +0200
@@ -156,7 +156,8 @@ const gint kEvents =
#if GTK_CHECK_VERSION(3, 4, 0)
GDK_SMOOTH_SCROLL_MASK | GDK_TOUCH_MASK |
@ -9,5 +9,5 @@ diff -up firefox-65.0/widget/gtk/nsWindow.cpp.1196777 firefox-65.0/widget/gtk/ns
+ GDK_SCROLL_MASK | GDK_POINTER_MOTION_MASK | GDK_PROPERTY_CHANGE_MASK |
+ GDK_FOCUS_CHANGE_MASK;
/* utility functions */
static bool is_mouse_in_window(GdkWindow *aWindow, gdouble aMouseX,
#if !GTK_CHECK_VERSION(3, 22, 0)
typedef enum {

View File

@ -1,203 +0,0 @@
diff -up firefox-67.0/widget/gtk/nsWindow.cpp.mozilla-1423598-popup firefox-67.0/widget/gtk/nsWindow.cpp
--- firefox-67.0/widget/gtk/nsWindow.cpp.mozilla-1423598-popup 2019-05-15 15:21:25.590222702 +0200
+++ firefox-67.0/widget/gtk/nsWindow.cpp 2019-05-15 15:24:26.925439991 +0200
@@ -1115,13 +1115,89 @@ void nsWindow::Move(double aX, double aY
NotifyRollupGeometryChange();
}
+#ifdef DEBUG
+static void NativeMoveResizeWaylandPopupCallback(GdkWindow *window,
+ const GdkRectangle *flipped_rect, const GdkRectangle *final_rect,
+ gboolean flipped_x, gboolean flipped_y, void *unused)
+{
+ LOG(("NativeMoveResizeWaylandPopupCallback flipped %d %d\n",
+ flipped_rect->x, flipped_rect->y));
+ LOG(("NativeMoveResizeWaylandPopupCallback final %d %d\n",
+ final_rect->x, final_rect->y));
+}
+#endif
+
+void nsWindow::NativeMoveResizeWaylandPopup(GdkPoint* aPosition, GdkRectangle* aSize) {
+ // Available as of GTK 3.24+
+ static auto sGdkWindowMoveToRect =
+ (void (*)(GdkWindow *, const GdkRectangle *, GdkGravity, GdkGravity,
+ GdkAnchorHints, gint, gint))
+ dlsym(RTLD_DEFAULT, "gdk_window_move_to_rect");
+
+ if (aSize) {
+ gtk_window_resize(GTK_WINDOW(mShell), aSize->width, aSize->height);
+ }
+ if (!sGdkWindowMoveToRect) {
+ gtk_window_move(GTK_WINDOW(mShell), aPosition->x, aPosition->y);
+ return;
+ }
+
+ GdkWindow *gdkWindow = gtk_widget_get_window(GTK_WIDGET(mShell));
+ if (!gdkWindow) {
+ return;
+ }
+
+ GtkWidget* parentWidget =
+ GTK_WIDGET(gtk_window_get_transient_for(GTK_WINDOW(mShell)));
+
+ int x_parent, y_parent;
+ gdk_window_get_origin(gtk_widget_get_window(parentWidget), &x_parent, &y_parent);
+
+ GdkRectangle rect = { aPosition->x - x_parent,
+ aPosition->y - y_parent,
+ 1, 1};
+ if (aSize) {
+ rect.width = aSize->width;
+ rect.height = aSize->height;
+ }
+
+#ifdef DEBUG
+ LOG(("NativeMoveResizeWaylandPopup request position %d,%d\n",
+ aPosition->x, aPosition->y));
+ if (aSize) {
+ LOG(("NativeMoveResizeWaylandPopup request size %d,%d\n",
+ aSize->width, aSize->height));
+ }
+ LOG(("NativeMoveResizeWaylandPopup result %d %d\n", rect.x, rect.y));
+ g_signal_connect(gdkWindow, "moved-to-rect",
+ G_CALLBACK(NativeMoveResizeWaylandPopupCallback), this);
+#endif
+
+ GdkGravity rectAnchor = GDK_GRAVITY_NORTH_WEST;
+ GdkGravity menuAnchor = GDK_GRAVITY_NORTH_WEST;
+ if (GetTextDirection() == GTK_TEXT_DIR_RTL) {
+ rectAnchor = GDK_GRAVITY_NORTH_EAST;
+ menuAnchor = GDK_GRAVITY_NORTH_EAST;
+ }
+
+ GdkAnchorHints hints = GdkAnchorHints(GDK_ANCHOR_SLIDE | GDK_ANCHOR_FLIP);
+ if (aSize) {
+ hints = GdkAnchorHints(hints|GDK_ANCHOR_RESIZE);
+ }
+
+ sGdkWindowMoveToRect(gdkWindow, &rect, rectAnchor, menuAnchor, hints, 0, 0);
+}
+
void nsWindow::NativeMove() {
GdkPoint point = DevicePixelsToGdkPointRoundDown(mBounds.TopLeft());
-
- if (mIsTopLevel) {
- gtk_window_move(GTK_WINDOW(mShell), point.x, point.y);
- } else if (mGdkWindow) {
- gdk_window_move(mGdkWindow, point.x, point.y);
+ if (!mIsX11Display && mIsTopLevel && mWindowType == eWindowType_popup) {
+ NativeMoveResizeWaylandPopup(&point, nullptr);
+ } else {
+ if (mIsTopLevel) {
+ gtk_window_move(GTK_WINDOW(mShell), point.x, point.y);
+ } else if (mGdkWindow) {
+ gdk_window_move(mGdkWindow, point.x, point.y);
+ }
}
}
@@ -3412,11 +3488,6 @@ nsresult nsWindow::Create(nsIWidget *aPa
GDK_WINDOW_TYPE_HINT_DIALOG);
gtk_window_set_transient_for(GTK_WINDOW(mShell), topLevelParent);
} else if (mWindowType == eWindowType_popup) {
- // With popup windows, we want to control their position, so don't
- // wait for the window manager to place them (which wouldn't
- // happen with override-redirect windows anyway).
- NativeMove();
-
gtk_window_set_wmclass(GTK_WINDOW(mShell), "Popup",
gdk_get_program_class());
@@ -3475,6 +3546,14 @@ nsresult nsWindow::Create(nsIWidget *aPa
if (topLevelParent) {
gtk_window_set_transient_for(GTK_WINDOW(mShell), topLevelParent);
}
+
+ // We need realized mShell at NativeMove().
+ gtk_widget_realize(mShell);
+
+ // With popup windows, we want to control their position, so don't
+ // wait for the window manager to place them (which wouldn't
+ // happen with override-redirect windows anyway).
+ NativeMove();
} else { // must be eWindowType_toplevel
SetDefaultIcon();
gtk_window_set_wmclass(GTK_WINDOW(mShell), "Toplevel",
@@ -3918,23 +3997,27 @@ void nsWindow::NativeMoveResize() {
LOG(("nsWindow::NativeMoveResize [%p] %d %d %d %d\n", (void *)this, topLeft.x,
topLeft.y, size.width, size.height));
- if (mIsTopLevel) {
- // x and y give the position of the window manager frame top-left.
- gtk_window_move(GTK_WINDOW(mShell), topLeft.x, topLeft.y);
- // This sets the client window size.
- MOZ_ASSERT(size.width > 0 && size.height > 0,
- "Can't resize window smaller than 1x1.");
- gtk_window_resize(GTK_WINDOW(mShell), size.width, size.height);
- } else if (mContainer) {
- GtkAllocation allocation;
- allocation.x = topLeft.x;
- allocation.y = topLeft.y;
- allocation.width = size.width;
- allocation.height = size.height;
- gtk_widget_size_allocate(GTK_WIDGET(mContainer), &allocation);
- } else if (mGdkWindow) {
- gdk_window_move_resize(mGdkWindow, topLeft.x, topLeft.y, size.width,
- size.height);
+ if (!mIsX11Display && mIsTopLevel && mWindowType == eWindowType_popup) {
+ NativeMoveResizeWaylandPopup(&topLeft, &size);
+ } else {
+ if (mIsTopLevel) {
+ // x and y give the position of the window manager frame top-left.
+ gtk_window_move(GTK_WINDOW(mShell), topLeft.x, topLeft.y);
+ // This sets the client window size.
+ MOZ_ASSERT(size.width > 0 && size.height > 0,
+ "Can't resize window smaller than 1x1.");
+ gtk_window_resize(GTK_WINDOW(mShell), size.width, size.height);
+ } else if (mContainer) {
+ GtkAllocation allocation;
+ allocation.x = topLeft.x;
+ allocation.y = topLeft.y;
+ allocation.width = size.width;
+ allocation.height = size.height;
+ gtk_widget_size_allocate(GTK_WIDGET(mContainer), &allocation);
+ } else if (mGdkWindow) {
+ gdk_window_move_resize(mGdkWindow, topLeft.x, topLeft.y, size.width,
+ size.height);
+ }
}
#ifdef MOZ_X11
@@ -6818,3 +6901,18 @@ void nsWindow::ForceTitlebarRedraw(void)
RestyleHint{0}, nsChangeHint_RepaintFrame);
}
}
+
+GtkTextDirection nsWindow::GetTextDirection() {
+ nsView *view = nsView::GetViewFor(this);
+ if (!view) {
+ return GTK_TEXT_DIR_LTR;
+ }
+ nsIFrame *frame = view->GetFrame();
+ if (!frame) {
+ return GTK_TEXT_DIR_LTR;
+ }
+
+ WritingMode wm = frame->GetWritingMode();
+ bool isFrameRTL = !(wm.IsVertical() ? wm.IsVerticalLR() : wm.IsBidiLTR());
+ return isFrameRTL ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR;
+}
diff -up firefox-67.0/widget/gtk/nsWindow.h.mozilla-1423598-popup firefox-67.0/widget/gtk/nsWindow.h
--- firefox-67.0/widget/gtk/nsWindow.h.mozilla-1423598-popup 2019-05-14 01:08:37.000000000 +0200
+++ firefox-67.0/widget/gtk/nsWindow.h 2019-05-15 15:21:25.890221541 +0200
@@ -460,6 +460,10 @@ class nsWindow final : public nsBaseWidg
nsWindow* GetTransientForWindowIfPopup();
bool IsHandlingTouchSequence(GdkEventSequence* aSequence);
+ void NativeMoveResizeWaylandPopup(GdkPoint* aPosition, GdkRectangle* aSize);
+
+ GtkTextDirection GetTextDirection();
+
#ifdef MOZ_X11
typedef enum {GTK_WIDGET_COMPOSIDED_DEFAULT = 0,
GTK_WIDGET_COMPOSIDED_DISABLED = 1,

View File

@ -1,256 +0,0 @@
diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -70,6 +70,10 @@
# include "mozilla/gfx/DeviceManagerDx.h"
#endif
+#ifdef MOZ_WAYLAND
+# include "mozilla/widget/nsWaylandDisplayShutdown.h"
+#endif
+
#include "nsGkAtoms.h"
#include "gfxPlatformFontList.h"
#include "gfxContext.h"
@@ -1276,6 +1280,9 @@
layers::PaintThread::Shutdown();
}
} else if (XRE_IsParentProcess()) {
+#ifdef MOZ_WAYLAND
+ widget::WaylandDisplayShutdown();
+#endif
gfx::VRManagerChild::ShutDown();
layers::CompositorManagerChild::Shutdown();
layers::ImageBridgeChild::ShutDown();
diff --git a/widget/gtk/WindowSurfaceWayland.cpp b/widget/gtk/WindowSurfaceWayland.cpp
--- a/widget/gtk/WindowSurfaceWayland.cpp
+++ b/widget/gtk/WindowSurfaceWayland.cpp
@@ -144,6 +144,8 @@
(wl_buffer/wl_surface).
*/
+#define EVENT_LOOP_DELAY (1000 / 240)
+
#define BUFFER_BPP 4
gfx::SurfaceFormat WindowBackBuffer::mFormat = gfx::SurfaceFormat::B8G8R8A8;
diff --git a/widget/gtk/moz.build b/widget/gtk/moz.build
--- a/widget/gtk/moz.build
+++ b/widget/gtk/moz.build
@@ -101,6 +101,9 @@
'nsWaylandDisplay.cpp',
'WindowSurfaceWayland.cpp',
]
+ EXPORTS.mozilla.widget += [
+ 'nsWaylandDisplayShutdown.h'
+ ]
if CONFIG['ACCESSIBILITY']:
UNIFIED_SOURCES += [
diff --git a/widget/gtk/nsAppShell.cpp b/widget/gtk/nsAppShell.cpp
--- a/widget/gtk/nsAppShell.cpp
+++ b/widget/gtk/nsAppShell.cpp
@@ -27,6 +27,9 @@
#include "ScreenHelperGTK.h"
#include "HeadlessScreenHelper.h"
#include "mozilla/widget/ScreenManager.h"
+#ifdef MOZ_WAYLAND
+# include "nsWaylandDisplay.h"
+#endif
using mozilla::LazyLogModule;
using mozilla::Unused;
@@ -267,5 +270,9 @@
}
bool nsAppShell::ProcessNextNativeEvent(bool mayWait) {
- return g_main_context_iteration(nullptr, mayWait);
+ bool ret = g_main_context_iteration(nullptr, mayWait);
+#ifdef MOZ_WAYLAND
+ WaylandDispatchDisplays();
+#endif
+ return ret;
}
diff --git a/widget/gtk/nsWaylandDisplay.h b/widget/gtk/nsWaylandDisplay.h
--- a/widget/gtk/nsWaylandDisplay.h
+++ b/widget/gtk/nsWaylandDisplay.h
@@ -14,10 +14,6 @@
namespace mozilla {
namespace widget {
-// TODO: Bug 1467125 - We need to integrate wl_display_dispatch_queue_pending()
-// with compositor event loop.
-#define EVENT_LOOP_DELAY (1000 / 240)
-
// Our general connection to Wayland display server,
// holds our display connection and runs event loop.
class nsWaylandDisplay {
@@ -25,9 +21,10 @@
explicit nsWaylandDisplay(wl_display* aDisplay);
virtual ~nsWaylandDisplay();
- bool DisplayLoop();
+ bool DispatchEventQueue();
bool Matches(wl_display* aDisplay);
+ MessageLoop* GetDispatcherThreadLoop() { return mDispatcherThreadLoop; }
wl_display* GetDisplay() { return mDisplay; };
wl_event_queue* GetEventQueue() { return mEventQueue; };
wl_subcompositor* GetSubcompositor(void) { return mSubcompositor; };
@@ -47,7 +44,10 @@
void SetPrimarySelectionDeviceManager(
gtk_primary_selection_device_manager* aPrimarySelectionDeviceManager);
+ void Shutdown();
+
private:
+ MessageLoop* mDispatcherThreadLoop;
PRThread* mThreadId;
wl_display* mDisplay;
wl_event_queue* mEventQueue;
@@ -59,6 +59,7 @@
wl_registry* mRegistry;
};
+void WaylandDispatchDisplays();
nsWaylandDisplay* WaylandDisplayGet(GdkDisplay* aGdkDisplay = nullptr);
} // namespace widget
diff --git a/widget/gtk/nsWaylandDisplay.cpp b/widget/gtk/nsWaylandDisplay.cpp
--- a/widget/gtk/nsWaylandDisplay.cpp
+++ b/widget/gtk/nsWaylandDisplay.cpp
@@ -21,6 +21,15 @@
static nsWaylandDisplay *gWaylandDisplays[MAX_DISPLAY_CONNECTIONS];
static StaticMutex gWaylandDisplaysMutex;
+void WaylandDisplayShutdown() {
+ StaticMutexAutoLock lock(gWaylandDisplaysMutex);
+ for (auto &display : gWaylandDisplays) {
+ if (display) {
+ display->Shutdown();
+ }
+ }
+}
+
static void ReleaseDisplaysAtExit() {
for (int i = 0; i < MAX_DISPLAY_CONNECTIONS; i++) {
delete gWaylandDisplays[i];
@@ -28,6 +37,10 @@
}
}
+static void DispatchDisplay(nsWaylandDisplay *aDisplay) {
+ aDisplay->DispatchEventQueue();
+}
+
// Each thread which is using wayland connection (wl_display) has to operate
// its own wl_event_queue. Main Firefox thread wl_event_queue is handled
// by Gtk main loop, other threads/wl_event_queue has to be handled by us.
@@ -35,7 +48,15 @@
// nsWaylandDisplay is our interface to wayland compositor. It provides wayland
// global objects as we need (wl_display, wl_shm) and operates wl_event_queue on
// compositor (not the main) thread.
-static void WaylandDisplayLoop(wl_display *aDisplay);
+void WaylandDispatchDisplays() {
+ StaticMutexAutoLock lock(gWaylandDisplaysMutex);
+ for (auto &display : gWaylandDisplays) {
+ if (display && display->GetDispatcherThreadLoop()) {
+ display->GetDispatcherThreadLoop()->PostTask(NewRunnableFunction(
+ "WaylandDisplayDispatch", &DispatchDisplay, display));
+ }
+ }
+}
// Get WaylandDisplay for given wl_display and actual calling thread.
static nsWaylandDisplay *WaylandDisplayGetLocked(GdkDisplay *aGdkDisplay,
@@ -73,27 +94,6 @@
return WaylandDisplayGetLocked(aGdkDisplay, lock);
}
-static void WaylandDisplayLoopLocked(wl_display *aDisplay,
- const StaticMutexAutoLock &) {
- for (auto &display : gWaylandDisplays) {
- if (display && display->Matches(aDisplay)) {
- if (display->DisplayLoop()) {
- MessageLoop::current()->PostDelayedTask(
- NewRunnableFunction("WaylandDisplayLoop", &WaylandDisplayLoop,
- aDisplay),
- EVENT_LOOP_DELAY);
- }
- break;
- }
- }
-}
-
-static void WaylandDisplayLoop(wl_display *aDisplay) {
- MOZ_ASSERT(!NS_IsMainThread());
- StaticMutexAutoLock lock(gWaylandDisplaysMutex);
- WaylandDisplayLoopLocked(aDisplay, lock);
-}
-
void nsWaylandDisplay::SetShm(wl_shm *aShm) { mShm = aShm; }
void nsWaylandDisplay::SetSubcompositor(wl_subcompositor *aSubcompositor) {
@@ -158,7 +158,7 @@
static const struct wl_registry_listener registry_listener = {
global_registry_handler, global_registry_remover};
-bool nsWaylandDisplay::DisplayLoop() {
+bool nsWaylandDisplay::DispatchEventQueue() {
wl_display_dispatch_queue_pending(mDisplay, mEventQueue);
return true;
}
@@ -168,7 +168,8 @@
}
nsWaylandDisplay::nsWaylandDisplay(wl_display *aDisplay)
- : mThreadId(PR_GetCurrentThread()),
+ : mDispatcherThreadLoop(nullptr),
+ mThreadId(PR_GetCurrentThread()),
mDisplay(aDisplay),
mEventQueue(nullptr),
mDataDeviceManager(nullptr),
@@ -186,15 +187,16 @@
wl_display_roundtrip(mDisplay);
wl_display_roundtrip(mDisplay);
} else {
+ mDispatcherThreadLoop = MessageLoop::current();
mEventQueue = wl_display_create_queue(mDisplay);
- MessageLoop::current()->PostTask(NewRunnableFunction(
- "WaylandDisplayLoop", &WaylandDisplayLoop, mDisplay));
wl_proxy_set_queue((struct wl_proxy *)mRegistry, mEventQueue);
wl_display_roundtrip_queue(mDisplay, mEventQueue);
wl_display_roundtrip_queue(mDisplay, mEventQueue);
}
}
+void nsWaylandDisplay::Shutdown() { mDispatcherThreadLoop = nullptr; }
+
nsWaylandDisplay::~nsWaylandDisplay() {
// Owned by Gtk+, we don't need to release
mDisplay = nullptr;
diff --git a/widget/gtk/nsWaylandDisplayShutdown.h b/widget/gtk/nsWaylandDisplayShutdown.h
new file mode 100644
--- /dev/null
+++ b/widget/gtk/nsWaylandDisplayShutdown.h
@@ -0,0 +1,19 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=4:tabstop=4:
+ */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef __MOZ_WAYLAND_DISPLAY_SHUTDOWN_H__
+#define __MOZ_WAYLAND_DISPLAY_SHUTDOWN_H__
+
+namespace mozilla {
+namespace widget {
+
+void WaylandDisplayShutdown();
+
+} // namespace widget
+} // namespace mozilla
+
+#endif // __MOZ_WAYLAND_DISPLAY_SHUTDOWN_H__

View File

@ -1,276 +0,0 @@
changeset: 465236:be9a6c98a4a7
tag: tip
user: Martin Stransky <stransky@redhat.com>
date: Mon Mar 18 10:42:48 2019 +0100
summary: tearing
diff --git a/widget/gtk/nsAppShell.cpp b/widget/gtk/nsAppShell.cpp
--- a/widget/gtk/nsAppShell.cpp
+++ b/widget/gtk/nsAppShell.cpp
@@ -35,16 +35,17 @@ using mozilla::widget::ScreenHelperGTK;
using mozilla::widget::ScreenManager;
#define NOTIFY_TOKEN 0xFA
LazyLogModule gWidgetLog("Widget");
LazyLogModule gWidgetFocusLog("WidgetFocus");
LazyLogModule gWidgetDragLog("WidgetDrag");
LazyLogModule gWidgetDrawLog("WidgetDraw");
+LazyLogModule gWidgetWaylandLog("WidgetWayland");
static GPollFunc sPollFunc;
// Wrapper function to disable hang monitoring while waiting in poll().
static gint PollWrapper(GPollFD* ufds, guint nfsd, gint timeout_) {
mozilla::BackgroundHangMonitor().NotifyWait();
gint result;
{
diff -up firefox-66.0/widget/gtk/WindowSurfaceWayland.cpp.old firefox-66.0/widget/gtk/WindowSurfaceWayland.cpp
--- firefox-66.0/widget/gtk/WindowSurfaceWayland.cpp.old 2019-03-20 15:48:52.265966904 +0100
+++ firefox-66.0/widget/gtk/WindowSurfaceWayland.cpp 2019-03-20 14:48:21.082035284 +0100
@@ -20,6 +20,18 @@
#include <fcntl.h>
#include <errno.h>
+#undef LOG
+#ifdef MOZ_LOGGING
+# include "mozilla/Logging.h"
+# include "nsTArray.h"
+# include "Units.h"
+extern mozilla::LazyLogModule gWidgetWaylandLog;
+# define LOGWAYLAND(args) \
+ MOZ_LOG(gWidgetWaylandLog, mozilla::LogLevel::Debug, args)
+#else
+# define LOGWAYLAND(args)
+#endif /* MOZ_LOGGING */
+
namespace mozilla {
namespace widget {
@@ -241,7 +253,7 @@ WaylandShmPool::~WaylandShmPool() {
static void buffer_release(void* data, wl_buffer* buffer) {
auto surface = reinterpret_cast<WindowBackBuffer*>(data);
- surface->Detach();
+ surface->Detach(buffer);
}
static const struct wl_buffer_listener buffer_listener = {buffer_release};
@@ -261,9 +273,16 @@ void WindowBackBuffer::Create(int aWidth
mWidth = aWidth;
mHeight = aHeight;
+
+ LOGWAYLAND((
+ "%s [%p] wl_buffer %p ID %d\n", __PRETTY_FUNCTION__, (void*)this,
+ (void*)mWaylandBuffer,
+ mWaylandBuffer ? wl_proxy_get_id((struct wl_proxy*)mWaylandBuffer) : -1));
}
void WindowBackBuffer::Release() {
+ LOGWAYLAND(("%s [%p]\n", __PRETTY_FUNCTION__, (void*)this));
+
wl_buffer_destroy(mWaylandBuffer);
mWidth = mHeight = 0;
}
@@ -288,6 +307,9 @@ WindowBackBuffer::~WindowBackBuffer() {
bool WindowBackBuffer::Resize(int aWidth, int aHeight) {
if (aWidth == mWidth && aHeight == mHeight) return true;
+ LOGWAYLAND(
+ ("%s [%p] %d %d\n", __PRETTY_FUNCTION__, (void*)this, aWidth, aHeight));
+
Release();
Create(aWidth, aHeight);
@@ -295,13 +317,26 @@ bool WindowBackBuffer::Resize(int aWidth
}
void WindowBackBuffer::Attach(wl_surface* aSurface) {
+ LOGWAYLAND((
+ "%s [%p] wl_surface %p ID %d wl_buffer %p ID %d\n", __PRETTY_FUNCTION__,
+ (void*)this, (void*)aSurface,
+ aSurface ? wl_proxy_get_id((struct wl_proxy*)aSurface) : -1,
+ (void*)mWaylandBuffer,
+ mWaylandBuffer ? wl_proxy_get_id((struct wl_proxy*)mWaylandBuffer) : -1));
+
wl_surface_attach(aSurface, mWaylandBuffer, 0, 0);
wl_surface_commit(aSurface);
wl_display_flush(mWaylandDisplay->GetDisplay());
mAttached = true;
}
-void WindowBackBuffer::Detach() { mAttached = false; }
+void WindowBackBuffer::Detach(wl_buffer* aBuffer) {
+ LOGWAYLAND(("%s [%p] wl_buffer %p ID %d\n", __PRETTY_FUNCTION__, (void*)this,
+ (void*)aBuffer,
+ aBuffer ? wl_proxy_get_id((struct wl_proxy*)aBuffer) : -1));
+
+ mAttached = false;
+}
bool WindowBackBuffer::SetImageDataFromBuffer(
class WindowBackBuffer* aSourceBuffer) {
@@ -316,6 +351,11 @@ bool WindowBackBuffer::SetImageDataFromB
}
already_AddRefed<gfx::DrawTarget> WindowBackBuffer::Lock() {
+ LOGWAYLAND((
+ "%s [%p] [%d x %d] wl_buffer %p ID %d\n", __PRETTY_FUNCTION__,
+ (void*)this, mWidth, mHeight, (void*)mWaylandBuffer,
+ mWaylandBuffer ? wl_proxy_get_id((struct wl_proxy*)mWaylandBuffer) : -1));
+
gfx::IntSize lockSize(mWidth, mHeight);
return gfxPlatform::CreateDrawTargetForData(
static_cast<unsigned char*>(mShmPool.GetImageData()), lockSize,
@@ -345,7 +385,8 @@ WindowSurfaceWayland::WindowSurfaceWayla
mPendingCommit(false),
mWaylandBufferFullScreenDamage(false),
mIsMainThread(NS_IsMainThread()),
- mNeedScaleFactorUpdate(true) {
+ mNeedScaleFactorUpdate(true),
+ mWaitToFullScreenUpdate(true) {
for (int i = 0; i < BACK_BUFFER_NUM; i++) mBackupBuffer[i] = nullptr;
}
@@ -387,7 +428,11 @@ WindowSurfaceWayland::~WindowSurfaceWayl
WindowBackBuffer* WindowSurfaceWayland::GetWaylandBufferToDraw(int aWidth,
int aHeight) {
if (!mWaylandBuffer) {
+ LOGWAYLAND(("%s [%p] Create [%d x %d]\n", __PRETTY_FUNCTION__, (void*)this,
+ aWidth, aHeight));
+
mWaylandBuffer = new WindowBackBuffer(mWaylandDisplay, aWidth, aHeight);
+ mWaitToFullScreenUpdate = true;
return mWaylandBuffer;
}
@@ -396,8 +441,11 @@ WindowBackBuffer* WindowSurfaceWayland::
mWaylandBuffer->Resize(aWidth, aHeight);
// There's a chance that scale factor has been changed
// when buffer size changed
- mNeedScaleFactorUpdate = true;
+ mWaitToFullScreenUpdate = true;
}
+ LOGWAYLAND(("%s [%p] Reuse buffer [%d x %d]\n", __PRETTY_FUNCTION__,
+ (void*)this, aWidth, aHeight));
+
return mWaylandBuffer;
}
@@ -420,6 +468,8 @@ WindowBackBuffer* WindowSurfaceWayland::
}
if (MOZ_UNLIKELY(availableBuffer == BACK_BUFFER_NUM)) {
+ LOGWAYLAND(("%s [%p] No drawing buffer available!\n", __PRETTY_FUNCTION__,
+ (void*)this));
NS_WARNING("No drawing buffer available");
return nullptr;
}
@@ -429,6 +479,8 @@ WindowBackBuffer* WindowSurfaceWayland::
mBackupBuffer[availableBuffer] = lastWaylandBuffer;
if (lastWaylandBuffer->IsMatchingSize(aWidth, aHeight)) {
+ LOGWAYLAND(("%s [%p] Copy from old buffer [%d x %d]\n", __PRETTY_FUNCTION__,
+ (void*)this, aWidth, aHeight));
// Former front buffer has the same size as a requested one.
// Gecko may expect a content already drawn on screen so copy
// existing data to the new buffer.
@@ -437,9 +489,12 @@ WindowBackBuffer* WindowSurfaceWayland::
// (https://bugzilla.redhat.com/show_bug.cgi?id=1418260)
mWaylandBufferFullScreenDamage = true;
} else {
+ LOGWAYLAND(("%s [%p] Resize to [%d x %d]\n", __PRETTY_FUNCTION__,
+ (void*)this, aWidth, aHeight));
// Former buffer has different size from the new request. Only resize
// the new buffer and leave gecko to render new whole content.
mWaylandBuffer->Resize(aWidth, aHeight);
+ mWaitToFullScreenUpdate = true;
}
return mWaylandBuffer;
@@ -499,6 +554,10 @@ already_AddRefed<gfx::DrawTarget> Window
gfx::IntRect bounds = aRegion.GetBounds().ToUnknownRect();
gfx::IntSize lockSize(bounds.XMost(), bounds.YMost());
+ LOGWAYLAND(("%s [%p] lockSize [%d x %d] screenSize [%d x %d]\n",
+ __PRETTY_FUNCTION__, (void*)this, lockSize.width, lockSize.height,
+ screenRect.width, lockSize.height));
+
// Are we asked for entire nsWindow to draw?
mDrawToWaylandBufferDirectly =
(aRegion.GetNumRects() == 1 && bounds.x == 0 && bounds.y == 0 &&
@@ -510,6 +569,13 @@ already_AddRefed<gfx::DrawTarget> Window
LockWaylandBuffer(screenRect.width, screenRect.height,
mWindow->WaylandSurfaceNeedsClear());
if (dt) {
+ // When we have a request to update whole screen at once
+ // (surface was created, resized or changed somehow)
+ // we also need update scale factor of the screen.
+ if (mWaitToFullScreenUpdate) {
+ mWaitToFullScreenUpdate = false;
+ mNeedScaleFactorUpdate = true;
+ }
return dt.forget();
}
@@ -576,6 +642,10 @@ static void WaylandBufferDelayCommitHand
void WindowSurfaceWayland::CommitWaylandBuffer() {
MOZ_ASSERT(mPendingCommit, "Committing empty surface!");
+ if (mWaitToFullScreenUpdate) {
+ return;
+ }
+
wl_surface* waylandSurface = mWindow->GetWaylandSurface();
if (!waylandSurface) {
// Target window is not created yet - delay the commit. This can happen only
@@ -619,6 +689,7 @@ void WindowSurfaceWayland::CommitWayland
LayoutDeviceIntRect rect = mWindow->GetBounds();
wl_surface_damage(waylandSurface, 0, 0, rect.width, rect.height);
mWaylandBufferFullScreenDamage = false;
+ mNeedScaleFactorUpdate = true;
} else {
gint scaleFactor = mWindow->GdkScaleFactor();
for (auto iter = mWaylandBufferDamage.RectIter(); !iter.Done();
@@ -653,6 +724,18 @@ void WindowSurfaceWayland::CommitWayland
void WindowSurfaceWayland::Commit(const LayoutDeviceIntRegion& aInvalidRegion) {
MOZ_ASSERT(mIsMainThread == NS_IsMainThread());
+#ifdef DEBUG
+ {
+ LayoutDeviceIntRect screenRect = mWindow->GetBounds();
+ gfx::IntRect bounds = aInvalidRegion.GetBounds().ToUnknownRect();
+ gfx::IntSize lockSize(bounds.XMost(), bounds.YMost());
+
+ LOGWAYLAND(("%s [%p] lockSize [%d x %d] screenSize [%d x %d]\n",
+ __PRETTY_FUNCTION__, (void*)this, lockSize.width,
+ lockSize.height, screenRect.width, lockSize.height));
+ }
+#endif
+
// We have new content at mImageSurface - copy data to mWaylandBuffer first.
if (!mDrawToWaylandBufferDirectly) {
CommitImageSurfaceToWaylandBuffer(aInvalidRegion);
diff -up firefox-66.0/widget/gtk/WindowSurfaceWayland.h.old firefox-66.0/widget/gtk/WindowSurfaceWayland.h
--- firefox-66.0/widget/gtk/WindowSurfaceWayland.h.old 2019-03-20 15:48:56.218949138 +0100
+++ firefox-66.0/widget/gtk/WindowSurfaceWayland.h 2019-03-20 14:48:21.082035284 +0100
@@ -46,7 +46,7 @@ class WindowBackBuffer {
already_AddRefed<gfx::DrawTarget> Lock();
void Attach(wl_surface* aSurface);
- void Detach();
+ void Detach(wl_buffer* aBuffer);
bool IsAttached() { return mAttached; }
void Clear();
@@ -118,6 +118,7 @@ class WindowSurfaceWayland : public Wind
bool mWaylandBufferFullScreenDamage;
bool mIsMainThread;
bool mNeedScaleFactorUpdate;
+ bool mWaitToFullScreenUpdate;
};
} // namespace widget

View File

@ -1,92 +0,0 @@
changeset: 468935:3b964face103
tag: tip
user: Martin Stransky <stransky@redhat.com>
date: Wed Apr 10 15:14:32 2019 +0200
summary: Bug 1508378 - Fix round error when damage rect size/position is odd number and scale factor is used, r=lsalzman
diff --git a/widget/gtk/WindowSurfaceWayland.cpp b/widget/gtk/WindowSurfaceWayland.cpp
--- a/widget/gtk/WindowSurfaceWayland.cpp
+++ b/widget/gtk/WindowSurfaceWayland.cpp
@@ -624,16 +624,33 @@ static void WaylandBufferDelayCommitHand
} else {
// Referenced WindowSurfaceWayland is already deleted.
// Do nothing but just release the mDelayedCommitHandle allocated at
// WindowSurfaceWayland::CommitWaylandBuffer().
free(aSurface);
}
}
+void WindowSurfaceWayland::CalcRectScale(LayoutDeviceIntRect& aRect, int aScale) {
+ if (aRect.x & 0x1) {
+ aRect.width += 1;
+ }
+ aRect.x = aRect.x / aScale;
+
+ if (aRect.y & 0x1) {
+ aRect.height += 1;
+ }
+ aRect.y = aRect.y / aScale;
+
+ aRect.width = (aRect.width & 0x1) ? aRect.width / aScale + 1 :
+ aRect.width / aScale;
+ aRect.height = (aRect.height & 0x1) ? aRect.height / aScale + 1 :
+ aRect.height / aScale;
+}
+
void WindowSurfaceWayland::CommitWaylandBuffer() {
MOZ_ASSERT(mPendingCommit, "Committing empty surface!");
if (mWaitToFullScreenUpdate) {
return;
}
wl_surface* waylandSurface = mWindow->GetWaylandSurface();
@@ -679,21 +696,23 @@ void WindowSurfaceWayland::CommitWayland
LayoutDeviceIntRect rect = mWindow->GetBounds();
wl_surface_damage(waylandSurface, 0, 0, rect.width, rect.height);
mWaylandBufferFullScreenDamage = false;
mNeedScaleFactorUpdate = true;
} else {
gint scaleFactor = mWindow->GdkScaleFactor();
for (auto iter = mWaylandBufferDamage.RectIter(); !iter.Done();
iter.Next()) {
- const mozilla::LayoutDeviceIntRect& r = iter.Get();
+ mozilla::LayoutDeviceIntRect r = iter.Get();
// We need to remove the scale factor because the wl_surface_damage
// also multiplies by current scale factor.
- wl_surface_damage(waylandSurface, r.x / scaleFactor, r.y / scaleFactor,
- r.width / scaleFactor, r.height / scaleFactor);
+ if (scaleFactor > 1) {
+ CalcRectScale(r, scaleFactor);
+ }
+ wl_surface_damage(waylandSurface, r.x, r.y, r.width, r.height);
}
}
// Clear all back buffer damage as we're committing
// all requested regions.
mWaylandBufferDamage.SetEmpty();
mFrameCallback = wl_surface_frame(waylandSurface);
diff --git a/widget/gtk/WindowSurfaceWayland.h b/widget/gtk/WindowSurfaceWayland.h
--- a/widget/gtk/WindowSurfaceWayland.h
+++ b/widget/gtk/WindowSurfaceWayland.h
@@ -96,16 +96,17 @@ class WindowSurfaceWayland : public Wind
WindowBackBuffer* GetWaylandBufferToDraw(int aWidth, int aHeight);
already_AddRefed<gfx::DrawTarget> LockWaylandBuffer(int aWidth, int aHeight,
bool aClearBuffer);
already_AddRefed<gfx::DrawTarget> LockImageSurface(
const gfx::IntSize& aLockSize);
bool CommitImageSurfaceToWaylandBuffer(const LayoutDeviceIntRegion& aRegion);
void CommitWaylandBuffer();
+ void CalcRectScale(LayoutDeviceIntRect& aRect, int scale);
// TODO: Do we need to hold a reference to nsWindow object?
nsWindow* mWindow;
nsWaylandDisplay* mWaylandDisplay;
WindowBackBuffer* mWaylandBuffer;
LayoutDeviceIntRegion mWaylandBufferDamage;
WindowBackBuffer* mBackupBuffer[BACK_BUFFER_NUM];
RefPtr<gfxImageSurface> mImageSurface;

View File

@ -1,209 +0,0 @@
diff -up firefox-67.0/widget/gtk/mozcontainer.cpp.mozilla-1517205 firefox-67.0/widget/gtk/mozcontainer.cpp
--- firefox-67.0/widget/gtk/mozcontainer.cpp.mozilla-1517205 2019-05-15 16:00:23.366366060 +0200
+++ firefox-67.0/widget/gtk/mozcontainer.cpp 2019-05-15 16:02:01.596967825 +0200
@@ -567,8 +567,7 @@ struct wl_surface *moz_container_get_wl_
moz_container_get_scale(container));
wl_surface_commit(container->surface);
- wl_display_flush(waylandDisplay->GetDisplay());
- WaylandDisplayRelease(waylandDisplay);
+ wl_display_flush(waylandDisplay->GetDisplay());
}
return container->surface;
diff -up firefox-67.0/widget/gtk/nsClipboardWayland.cpp.mozilla-1517205 firefox-67.0/widget/gtk/nsClipboardWayland.cpp
--- firefox-67.0/widget/gtk/nsClipboardWayland.cpp.mozilla-1517205 2019-05-14 01:08:37.000000000 +0200
+++ firefox-67.0/widget/gtk/nsClipboardWayland.cpp 2019-05-15 16:00:23.367366056 +0200
@@ -639,7 +639,6 @@ static gboolean offer_hash_remove(gpoint
nsRetrievalContextWayland::~nsRetrievalContextWayland(void) {
g_hash_table_foreach_remove(mActiveOffers, offer_hash_remove, nullptr);
g_hash_table_destroy(mActiveOffers);
- WaylandDisplayRelease(mDisplay);
}
GdkAtom *nsRetrievalContextWayland::GetTargets(int32_t aWhichClipboard,
diff -up firefox-67.0/widget/gtk/nsWaylandDisplay.cpp.mozilla-1517205 firefox-67.0/widget/gtk/nsWaylandDisplay.cpp
--- firefox-67.0/widget/gtk/nsWaylandDisplay.cpp.mozilla-1517205 2019-05-14 01:08:37.000000000 +0200
+++ firefox-67.0/widget/gtk/nsWaylandDisplay.cpp 2019-05-15 16:00:23.368366052 +0200
@@ -21,6 +21,13 @@ namespace widget {
static nsWaylandDisplay *gWaylandDisplays[MAX_DISPLAY_CONNECTIONS];
static StaticMutex gWaylandDisplaysMutex;
+static void ReleaseDisplaysAtExit() {
+ for (int i = 0; i < MAX_DISPLAY_CONNECTIONS; i++) {
+ delete gWaylandDisplays[i];
+ gWaylandDisplays[i] = nullptr;
+ }
+}
+
// Each thread which is using wayland connection (wl_display) has to operate
// its own wl_event_queue. Main Firefox thread wl_event_queue is handled
// by Gtk main loop, other threads/wl_event_queue has to be handled by us.
@@ -35,7 +42,6 @@ static nsWaylandDisplay *WaylandDisplayG
const StaticMutexAutoLock &) {
for (auto &display : gWaylandDisplays) {
if (display && display->Matches(aDisplay)) {
- NS_ADDREF(display);
return display;
}
}
@@ -43,7 +49,7 @@ static nsWaylandDisplay *WaylandDisplayG
for (auto &display : gWaylandDisplays) {
if (display == nullptr) {
display = new nsWaylandDisplay(aDisplay);
- NS_ADDREF(display);
+ atexit(ReleaseDisplaysAtExit);
return display;
}
}
@@ -67,26 +73,6 @@ nsWaylandDisplay *WaylandDisplayGet(GdkD
return WaylandDisplayGetLocked(display, lock);
}
-static bool WaylandDisplayReleaseLocked(nsWaylandDisplay *aDisplay,
- const StaticMutexAutoLock &) {
- for (auto &display : gWaylandDisplays) {
- if (display == aDisplay) {
- int rc = display->Release();
- if (rc == 0) {
- display = nullptr;
- }
- return true;
- }
- }
- MOZ_ASSERT(false, "Missing nsWaylandDisplay for this thread!");
- return false;
-}
-
-void WaylandDisplayRelease(nsWaylandDisplay *aDisplay) {
- StaticMutexAutoLock lock(gWaylandDisplaysMutex);
- WaylandDisplayReleaseLocked(aDisplay, lock);
-}
-
static void WaylandDisplayLoopLocked(wl_display *aDisplay,
const StaticMutexAutoLock &) {
for (auto &display : gWaylandDisplays) {
@@ -130,6 +116,8 @@ static void global_registry_handler(void
uint32_t id, const char *interface,
uint32_t version) {
auto display = reinterpret_cast<nsWaylandDisplay *>(data);
+ if (!display)
+ return;
if (strcmp(interface, "wl_shm") == 0) {
auto shm = static_cast<wl_shm *>(
@@ -180,9 +168,7 @@ bool nsWaylandDisplay::Matches(wl_displa
return mThreadId == PR_GetCurrentThread() && aDisplay == mDisplay;
}
-NS_IMPL_ISUPPORTS(nsWaylandDisplay, nsISupports);
-
-nsWaylandDisplay::nsWaylandDisplay(wl_display *aDisplay)
+nsWaylandDisplay::nsWaylandDisplay(wl_display* aDisplay)
: mThreadId(PR_GetCurrentThread()),
mDisplay(aDisplay),
mEventQueue(nullptr),
@@ -190,9 +176,10 @@ nsWaylandDisplay::nsWaylandDisplay(wl_di
mSubcompositor(nullptr),
mSeat(nullptr),
mShm(nullptr),
- mPrimarySelectionDeviceManager(nullptr) {
- wl_registry *registry = wl_display_get_registry(mDisplay);
- wl_registry_add_listener(registry, &registry_listener, this);
+ mPrimarySelectionDeviceManager(nullptr),
+ mRegistry(nullptr) {
+ mRegistry = wl_display_get_registry(mDisplay);
+ wl_registry_add_listener(mRegistry, &registry_listener, this);
if (NS_IsMainThread()) {
// Use default event queue in main thread operated by Gtk+.
@@ -203,17 +190,19 @@ nsWaylandDisplay::nsWaylandDisplay(wl_di
mEventQueue = wl_display_create_queue(mDisplay);
MessageLoop::current()->PostTask(NewRunnableFunction(
"WaylandDisplayLoop", &WaylandDisplayLoop, mDisplay));
- wl_proxy_set_queue((struct wl_proxy *)registry, mEventQueue);
+ wl_proxy_set_queue((struct wl_proxy *)mRegistry, mEventQueue);
wl_display_roundtrip_queue(mDisplay, mEventQueue);
wl_display_roundtrip_queue(mDisplay, mEventQueue);
}
}
nsWaylandDisplay::~nsWaylandDisplay() {
- MOZ_ASSERT(mThreadId == PR_GetCurrentThread());
// Owned by Gtk+, we don't need to release
mDisplay = nullptr;
+ wl_registry_destroy(mRegistry);
+ mRegistry = nullptr;
+
if (mEventQueue) {
wl_event_queue_destroy(mEventQueue);
mEventQueue = nullptr;
diff -up firefox-67.0/widget/gtk/nsWaylandDisplay.h.mozilla-1517205 firefox-67.0/widget/gtk/nsWaylandDisplay.h
--- firefox-67.0/widget/gtk/nsWaylandDisplay.h.mozilla-1517205 2019-05-14 01:08:27.000000000 +0200
+++ firefox-67.0/widget/gtk/nsWaylandDisplay.h 2019-05-15 16:00:23.368366052 +0200
@@ -20,11 +20,10 @@ namespace widget {
// Our general connection to Wayland display server,
// holds our display connection and runs event loop.
-class nsWaylandDisplay : public nsISupports {
- NS_DECL_THREADSAFE_ISUPPORTS
-
+class nsWaylandDisplay {
public:
explicit nsWaylandDisplay(wl_display* aDisplay);
+ virtual ~nsWaylandDisplay();
bool DisplayLoop();
bool Matches(wl_display* aDisplay);
@@ -41,7 +40,6 @@ class nsWaylandDisplay : public nsISuppo
return mPrimarySelectionDeviceManager;
};
- public:
void SetShm(wl_shm* aShm);
void SetSubcompositor(wl_subcompositor* aSubcompositor);
void SetDataDeviceManager(wl_data_device_manager* aDataDeviceManager);
@@ -49,9 +47,7 @@ class nsWaylandDisplay : public nsISuppo
void SetPrimarySelectionDeviceManager(
gtk_primary_selection_device_manager* aPrimarySelectionDeviceManager);
- private:
- virtual ~nsWaylandDisplay();
-
+private:
PRThread* mThreadId;
wl_display* mDisplay;
wl_event_queue* mEventQueue;
@@ -60,10 +56,10 @@ class nsWaylandDisplay : public nsISuppo
wl_seat* mSeat;
wl_shm* mShm;
gtk_primary_selection_device_manager* mPrimarySelectionDeviceManager;
+ wl_registry *mRegistry;
};
nsWaylandDisplay* WaylandDisplayGet(GdkDisplay* aGdkDisplay = nullptr);
-void WaylandDisplayRelease(nsWaylandDisplay* aDisplay);
} // namespace widget
} // namespace mozilla
diff -up firefox-67.0/widget/gtk/WindowSurfaceWayland.cpp.mozilla-1517205 firefox-67.0/widget/gtk/WindowSurfaceWayland.cpp
--- firefox-67.0/widget/gtk/WindowSurfaceWayland.cpp.mozilla-1517205 2019-05-15 16:00:23.335366185 +0200
+++ firefox-67.0/widget/gtk/WindowSurfaceWayland.cpp 2019-05-15 16:00:23.368366052 +0200
@@ -413,16 +413,6 @@ WindowSurfaceWayland::~WindowSurfaceWayl
delete mBackupBuffer[i];
}
}
-
- if (!mIsMainThread) {
- // We can be destroyed from main thread even though we was created/used
- // in compositor thread. We have to unref/delete WaylandDisplay in
- // compositor thread then and we can't use MessageLoop::current() here.
- mDisplayThreadMessageLoop->PostTask(NewRunnableFunction(
- "WaylandDisplayRelease", &WaylandDisplayRelease, mWaylandDisplay));
- } else {
- WaylandDisplayRelease(mWaylandDisplay);
- }
}
WindowBackBuffer* WindowSurfaceWayland::GetWaylandBufferToDraw(int aWidth,

View File

@ -1,340 +0,0 @@
changeset: 465480:a86f3560fb17
parent: 465477:26d9b7ffbd6b
user: Martin Stransky <stransky@redhat.com>
date: Fri Mar 29 15:30:15 2019 +0100
summary: Bug 1526243 - [Linux] Don't use nsGConfService in nsGNOMEShellService.cpp, r=glandium
diff --git a/browser/components/shell/nsGNOMEShellService.cpp b/browser/components/shell/nsGNOMEShellService.cpp
--- a/browser/components/shell/nsGNOMEShellService.cpp
+++ b/browser/components/shell/nsGNOMEShellService.cpp
@@ -10,17 +10,16 @@
#include "nsShellService.h"
#include "nsIServiceManager.h"
#include "nsIFile.h"
#include "nsIProperties.h"
#include "nsDirectoryServiceDefs.h"
#include "nsIPrefService.h"
#include "prenv.h"
#include "nsString.h"
-#include "nsIGConfService.h"
#include "nsIGIOService.h"
#include "nsIGSettingsService.h"
#include "nsIStringBundle.h"
#include "nsIOutputStream.h"
#include "nsIProcess.h"
#include "nsServiceManagerUtils.h"
#include "nsComponentManagerUtils.h"
#include "nsIImageLoadingContent.h"
@@ -65,48 +64,39 @@ static const ProtocolAssociation appProt
static const MimeTypeAssociation appTypes[] = {
// clang-format off
{ "text/html", "htm html shtml" },
{ "application/xhtml+xml", "xhtml xht" }
// clang-format on
};
-// GConf registry key constants
-#define DG_BACKGROUND "/desktop/gnome/background"
-
-#define kDesktopImageKey DG_BACKGROUND "/picture_filename"
-#define kDesktopOptionsKey DG_BACKGROUND "/picture_options"
-#define kDesktopDrawBGKey DG_BACKGROUND "/draw_background"
-#define kDesktopColorKey DG_BACKGROUND "/primary_color"
-
#define kDesktopBGSchema "org.gnome.desktop.background"
#define kDesktopImageGSKey "picture-uri"
#define kDesktopOptionGSKey "picture-options"
#define kDesktopDrawBGGSKey "draw-background"
#define kDesktopColorGSKey "primary-color"
static bool IsRunningAsASnap() { return (PR_GetEnv("SNAP") != nullptr); }
nsresult nsGNOMEShellService::Init() {
nsresult rv;
if (gfxPlatform::IsHeadless()) {
return NS_ERROR_NOT_AVAILABLE;
}
- // GConf, GSettings or GIO _must_ be available, or we do not allow
+ // GSettings or GIO _must_ be available, or we do not allow
// CreateInstance to succeed.
- nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
nsCOMPtr<nsIGSettingsService> gsettings =
do_GetService(NS_GSETTINGSSERVICE_CONTRACTID);
- if (!gconf && !giovfs && !gsettings) return NS_ERROR_NOT_AVAILABLE;
+ if (!giovfs && !gsettings) return NS_ERROR_NOT_AVAILABLE;
// Check G_BROKEN_FILENAMES. If it's set, then filenames in glib use
// the locale encoding. If it's not set, they use UTF-8.
mUseLocaleFilenames = PR_GetEnv("G_BROKEN_FILENAMES") != nullptr;
if (GetAppPathFromLauncher()) return NS_OK;
nsCOMPtr<nsIProperties> dirSvc(
@@ -212,35 +202,23 @@ nsGNOMEShellService::IsDefaultBrowser(bo
}
if (strcmp(output, "yes\n") == 0) {
*aIsDefaultBrowser = true;
}
g_free(output);
return NS_OK;
}
- nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
-
- bool enabled;
nsAutoCString handler;
nsCOMPtr<nsIGIOMimeApp> gioApp;
for (unsigned int i = 0; i < ArrayLength(appProtocols); ++i) {
if (!appProtocols[i].essential) continue;
- if (gconf) {
- handler.Truncate();
- gconf->GetAppForProtocol(nsDependentCString(appProtocols[i].name),
- &enabled, handler);
-
- if (!CheckHandlerMatchesAppName(handler) || !enabled)
- return NS_OK; // the handler is disabled or set to another app
- }
-
if (giovfs) {
handler.Truncate();
nsCOMPtr<nsIHandlerApp> handlerApp;
giovfs->GetAppForURIScheme(nsDependentCString(appProtocols[i].name),
getter_AddRefs(handlerApp));
gioApp = do_QueryInterface(handlerApp);
if (!gioApp) return NS_OK;
@@ -270,39 +248,17 @@ nsGNOMEShellService::SetDefaultBrowser(b
GSpawnFlags flags = static_cast<GSpawnFlags>(G_SPAWN_SEARCH_PATH |
G_SPAWN_STDOUT_TO_DEV_NULL |
G_SPAWN_STDERR_TO_DEV_NULL);
g_spawn_sync(nullptr, (gchar **)argv, nullptr, flags, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr);
return NS_OK;
}
- nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
- if (gconf) {
- nsAutoCString appKeyValue;
- if (mAppIsInPath) {
- // mAppPath is in the users path, so use only the basename as the launcher
- gchar *tmp = g_path_get_basename(mAppPath.get());
- appKeyValue = tmp;
- g_free(tmp);
- } else {
- appKeyValue = mAppPath;
- }
-
- appKeyValue.AppendLiteral(" %s");
-
- for (unsigned int i = 0; i < ArrayLength(appProtocols); ++i) {
- if (appProtocols[i].essential || aClaimAllTypes) {
- gconf->SetAppForProtocol(nsDependentCString(appProtocols[i].name),
- appKeyValue);
- }
- }
- }
-
if (giovfs) {
nsresult rv;
nsCOMPtr<nsIStringBundleService> bundleService =
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIStringBundle> brandBundle;
rv = bundleService->CreateBundle(BRAND_PROPERTIES,
@@ -353,19 +309,21 @@ nsGNOMEShellService::SetDefaultBrowser(b
}
return NS_OK;
}
NS_IMETHODIMP
nsGNOMEShellService::GetCanSetDesktopBackground(bool *aResult) {
// setting desktop background is currently only supported
- // for Gnome or desktops using the same GSettings and GConf keys
- const char *gnomeSession = getenv("GNOME_DESKTOP_SESSION_ID");
- if (gnomeSession) {
+ // for Gnome or desktops using the same GSettings keys
+ const char *currentDesktop = getenv("XDG_CURRENT_DESKTOP");
+ if (currentDesktop &&
+ (strstr(currentDesktop, "GNOME-Flashback:GNOME") != nullptr ||
+ strstr(currentDesktop, "GNOME") != nullptr)) {
*aResult = true;
} else {
*aResult = false;
}
return NS_OK;
}
@@ -439,20 +397,16 @@ nsGNOMEShellService::SetDesktopBackgroun
filePath.Append('/');
filePath.Append(NS_ConvertUTF16toUTF8(brandName));
filePath.AppendLiteral("_wallpaper.png");
// write the image to a file in the home dir
rv = WriteImage(filePath, container);
NS_ENSURE_SUCCESS(rv, rv);
- // Try GSettings first. If we don't have GSettings or the right schema, fall
- // back to using GConf instead. Note that if GSettings works ok, the changes
- // get mirrored to GConf by the gsettings->gconf bridge in
- // gnome-settings-daemon
nsCOMPtr<nsIGSettingsService> gsettings =
do_GetService(NS_GSETTINGSSERVICE_CONTRACTID);
if (gsettings) {
nsCOMPtr<nsIGSettingsCollection> background_settings;
gsettings->GetCollectionForSchema(NS_LITERAL_CSTRING(kDesktopBGSchema),
getter_AddRefs(background_settings));
if (background_settings) {
gchar *file_uri = g_filename_to_uri(filePath.get(), nullptr, nullptr);
@@ -465,32 +419,17 @@ nsGNOMEShellService::SetDesktopBackgroun
nsDependentCString(file_uri));
g_free(file_uri);
background_settings->SetBoolean(NS_LITERAL_CSTRING(kDesktopDrawBGGSKey),
true);
return rv;
}
}
- // if the file was written successfully, set it as the system wallpaper
- nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
-
- if (gconf) {
- gconf->SetString(NS_LITERAL_CSTRING(kDesktopOptionsKey), options);
-
- // Set the image to an empty string first to force a refresh
- // (since we could be writing a new image on top of an existing
- // Firefox_wallpaper.png and nautilus doesn't monitor the file for changes)
- gconf->SetString(NS_LITERAL_CSTRING(kDesktopImageKey), EmptyCString());
-
- gconf->SetString(NS_LITERAL_CSTRING(kDesktopImageKey), filePath);
- gconf->SetBool(NS_LITERAL_CSTRING(kDesktopDrawBGKey), true);
- }
-
- return rv;
+ return NS_ERROR_FAILURE;
}
#define COLOR_16_TO_8_BIT(_c) ((_c) >> 8)
#define COLOR_8_TO_16_BIT(_c) ((_c) << 8 | (_c))
NS_IMETHODIMP
nsGNOMEShellService::GetDesktopBackgroundColor(uint32_t *aColor) {
nsCOMPtr<nsIGSettingsService> gsettings =
@@ -502,22 +441,16 @@ nsGNOMEShellService::GetDesktopBackgroun
gsettings->GetCollectionForSchema(NS_LITERAL_CSTRING(kDesktopBGSchema),
getter_AddRefs(background_settings));
if (background_settings) {
background_settings->GetString(NS_LITERAL_CSTRING(kDesktopColorGSKey),
background);
}
}
- if (!background_settings) {
- nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
- if (gconf)
- gconf->GetString(NS_LITERAL_CSTRING(kDesktopColorKey), background);
- }
-
if (background.IsEmpty()) {
*aColor = 0;
return NS_OK;
}
GdkColor color;
gboolean success = gdk_color_parse(background.get(), &color);
@@ -555,23 +488,17 @@ nsGNOMEShellService::SetDesktopBackgroun
getter_AddRefs(background_settings));
if (background_settings) {
background_settings->SetString(NS_LITERAL_CSTRING(kDesktopColorGSKey),
colorString);
return NS_OK;
}
}
- nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
-
- if (gconf) {
- gconf->SetString(NS_LITERAL_CSTRING(kDesktopColorKey), colorString);
- }
-
- return NS_OK;
+ return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsGNOMEShellService::OpenApplication(int32_t aApplication) {
nsAutoCString scheme;
if (aApplication == APPLICATION_MAIL)
scheme.AssignLiteral("mailto");
else if (aApplication == APPLICATION_NEWS)
@@ -581,55 +508,17 @@ nsGNOMEShellService::OpenApplication(int
nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
if (giovfs) {
nsCOMPtr<nsIHandlerApp> handlerApp;
giovfs->GetAppForURIScheme(scheme, getter_AddRefs(handlerApp));
if (handlerApp) return handlerApp->LaunchWithURI(nullptr, nullptr);
}
- nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
- if (!gconf) return NS_ERROR_FAILURE;
-
- bool enabled;
- nsAutoCString appCommand;
- gconf->GetAppForProtocol(scheme, &enabled, appCommand);
-
- if (!enabled) return NS_ERROR_FAILURE;
-
- // XXX we don't currently handle launching a terminal window.
- // If the handler requires a terminal, bail.
- bool requiresTerminal;
- gconf->HandlerRequiresTerminal(scheme, &requiresTerminal);
- if (requiresTerminal) return NS_ERROR_FAILURE;
-
- // Perform shell argument expansion
- int argc;
- char **argv;
- if (!g_shell_parse_argv(appCommand.get(), &argc, &argv, nullptr))
- return NS_ERROR_FAILURE;
-
- char **newArgv = new char *[argc + 1];
- int newArgc = 0;
-
- // Run through the list of arguments. Copy all of them to the new
- // argv except for %s, which we skip.
- for (int i = 0; i < argc; ++i) {
- if (strcmp(argv[i], "%s") != 0) newArgv[newArgc++] = argv[i];
- }
-
- newArgv[newArgc] = nullptr;
-
- gboolean err = g_spawn_async(nullptr, newArgv, nullptr, G_SPAWN_SEARCH_PATH,
- nullptr, nullptr, nullptr, nullptr);
-
- g_strfreev(argv);
- delete[] newArgv;
-
- return err ? NS_OK : NS_ERROR_FAILURE;
+ return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsGNOMEShellService::OpenApplicationWithURI(nsIFile *aApplication,
const nsACString &aURI) {
nsresult rv;
nsCOMPtr<nsIProcess> process =
do_CreateInstance("@mozilla.org/process/util;1", &rv);

View File

@ -1,71 +0,0 @@
diff -up firefox-67.0/layout/xul/moz.build.mozilla-1532643-popup firefox-67.0/layout/xul/moz.build
--- firefox-67.0/layout/xul/moz.build.mozilla-1532643-popup 2019-05-14 01:08:24.000000000 +0200
+++ firefox-67.0/layout/xul/moz.build 2019-05-15 15:31:39.714299754 +0200
@@ -88,3 +88,6 @@ LOCAL_INCLUDES += [
if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
CXXFLAGS += ['-Wno-error=shadow']
+
+CFLAGS += CONFIG['TK_CFLAGS']
+CXXFLAGS += CONFIG['TK_CFLAGS']
diff -up firefox-67.0/layout/xul/nsMenuPopupFrame.cpp.mozilla-1532643-popup firefox-67.0/layout/xul/nsMenuPopupFrame.cpp
--- firefox-67.0/layout/xul/nsMenuPopupFrame.cpp.mozilla-1532643-popup 2019-05-14 01:08:24.000000000 +0200
+++ firefox-67.0/layout/xul/nsMenuPopupFrame.cpp 2019-05-15 15:37:01.121215863 +0200
@@ -55,6 +55,10 @@
#include "mozilla/dom/KeyboardEvent.h"
#include "mozilla/dom/KeyboardEventBinding.h"
#include <algorithm>
+#ifdef MOZ_WAYLAND
+#include <gdk/gdk.h>
+#include <gdk/gdkx.h>
+#endif /* MOZ_WAYLAND */
using namespace mozilla;
using mozilla::dom::Document;
@@ -301,11 +305,29 @@ nsresult nsMenuPopupFrame::CreateWidgetF
!(mode == eTransparencyTransparent || tag == nsGkAtoms::menulist);
widgetData.mPopupLevel = PopupLevel(widgetData.mNoAutoHide);
+ static bool waylandBackend =
+#ifdef MOZ_WAYLAND
+ !GDK_IS_X11_DISPLAY(gdk_display_get_default());
+#else
+ false;
+#endif
+
// panels which have a parent level need a parent widget. This allows them to
// always appear in front of the parent window but behind other windows that
// should be in front of it.
nsCOMPtr<nsIWidget> parentWidget;
- if (widgetData.mPopupLevel != ePopupLevelTop) {
+ if (waylandBackend) {
+ // On Wayland we always need to connect menu to its parent menu widget
+ // otherwise it's not shown.
+ nsMenuFrame* menuFrame = do_QueryFrame(GetParent());
+ if (menuFrame) {
+ nsMenuParent* parentPopup = menuFrame->GetMenuParent();
+ if (parentPopup && parentPopup->IsMenu()) {
+ parentWidget =
+ static_cast<nsMenuPopupFrame*>(parentPopup)->GetWidget();
+ }
+ }
+ } else if (widgetData.mPopupLevel != ePopupLevelTop) {
nsCOMPtr<nsIDocShellTreeItem> dsti = PresContext()->GetDocShell();
if (!dsti) return NS_ERROR_FAILURE;
diff -up firefox-67.0/widget/gtk/nsWindow.cpp.mozilla-1532643-popup firefox-67.0/widget/gtk/nsWindow.cpp
--- firefox-67.0/widget/gtk/nsWindow.cpp.mozilla-1532643-popup 2019-05-15 15:31:39.712299764 +0200
+++ firefox-67.0/widget/gtk/nsWindow.cpp 2019-05-15 15:31:39.716299744 +0200
@@ -3527,11 +3527,7 @@ nsresult nsWindow::Create(nsIWidget *aPa
} else {
switch (aInitData->mPopupHint) {
case ePopupTypeMenu:
- // Use GDK_WINDOW_TYPE_HINT_UTILITY on Wayland which
- // guides Gtk to create the popup as subsurface
- // instead of xdg_shell popup (see Bug 1423598).
- gtkTypeHint = mIsX11Display ? GDK_WINDOW_TYPE_HINT_POPUP_MENU
- : GDK_WINDOW_TYPE_HINT_UTILITY;
+ gtkTypeHint = GDK_WINDOW_TYPE_HINT_POPUP_MENU;
break;
case ePopupTypeTooltip:
gtkTypeHint = GDK_WINDOW_TYPE_HINT_TOOLTIP;

View File

@ -1,136 +0,0 @@
diff -up firefox-67.0/widget/gtk/mozcontainer.cpp.mozilla-1535567 firefox-67.0/widget/gtk/mozcontainer.cpp
--- firefox-67.0/widget/gtk/mozcontainer.cpp.mozilla-1535567 2019-05-14 01:08:37.000000000 +0200
+++ firefox-67.0/widget/gtk/mozcontainer.cpp 2019-05-15 15:56:19.645336209 +0200
@@ -157,6 +157,7 @@ void moz_container_init(MozContainer *co
container->subsurface = nullptr;
container->eglwindow = nullptr;
container->frame_callback_handler = nullptr;
+ container->frame_callback_handler_surface_id = -1;
// We can draw to x11 window any time.
container->ready_to_draw = GDK_IS_X11_DISPLAY(gdk_display_get_default());
container->surface_needs_clear = true;
@@ -165,6 +166,11 @@ void moz_container_init(MozContainer *co
}
#if defined(MOZ_WAYLAND)
+void moz_container_set_initial_draw_callback(
+ MozContainer *container, std::function<void(void)> inital_draw_cb) {
+ container->inital_draw_cb = inital_draw_cb;
+}
+
static wl_surface *moz_container_get_gtk_container_surface(
MozContainer *container) {
static auto sGdkWaylandWindowGetWlSurface = (wl_surface * (*)(GdkWindow *))
@@ -178,37 +184,61 @@ static void frame_callback_handler(void
uint32_t time) {
MozContainer *container = MOZ_CONTAINER(data);
g_clear_pointer(&container->frame_callback_handler, wl_callback_destroy);
+ container->frame_callback_handler_surface_id = -1;
if (!container->ready_to_draw && container->inital_draw_cb) {
container->inital_draw_cb();
}
container->ready_to_draw = true;
}
-void moz_container_set_initial_draw_callback(
- MozContainer *container, std::function<void(void)> inital_draw_cb) {
- container->inital_draw_cb = inital_draw_cb;
-}
-
static const struct wl_callback_listener frame_listener = {
frame_callback_handler};
-static gboolean moz_container_map_wayland(GtkWidget *widget,
- GdkEventAny *event) {
- MozContainer *container = MOZ_CONTAINER(widget);
-
- if (container->ready_to_draw || container->frame_callback_handler) {
- return FALSE;
- }
-
+static void moz_container_request_parent_frame_callback(
+ MozContainer *container) {
wl_surface *gtk_container_surface =
moz_container_get_gtk_container_surface(container);
+ int gtk_container_surface_id =
+ gtk_container_surface
+ ? wl_proxy_get_id((struct wl_proxy *)gtk_container_surface)
+ : -1;
+
+
+
+
+
+
+
+ if (container->frame_callback_handler &&
+ container->frame_callback_handler_surface_id ==
+ gtk_container_surface_id) {
+ return;
+ }
+
+ // If there's pending frame callback, delete it.
+ if (container->frame_callback_handler) {
+ g_clear_pointer(&container->frame_callback_handler, wl_callback_destroy);
+ }
if (gtk_container_surface) {
+ container->frame_callback_handler_surface_id = gtk_container_surface_id;
container->frame_callback_handler = wl_surface_frame(gtk_container_surface);
wl_callback_add_listener(container->frame_callback_handler, &frame_listener,
container);
+ } else {
+ container->frame_callback_handler_surface_id = -1;
+ }
+}
+
+static gboolean moz_container_map_wayland(GtkWidget *widget,
+ GdkEventAny *event) {
+ MozContainer *container = MOZ_CONTAINER(widget);
+
+ if (container->ready_to_draw) {
+ return FALSE;
}
+ moz_container_request_parent_frame_callback(MOZ_CONTAINER(widget));
return FALSE;
}
@@ -217,6 +247,7 @@ static void moz_container_unmap_wayland(
g_clear_pointer(&container->subsurface, wl_subsurface_destroy);
g_clear_pointer(&container->surface, wl_surface_destroy);
g_clear_pointer(&container->frame_callback_handler, wl_callback_destroy);
+ container->frame_callback_handler_surface_id = -1;
container->surface_needs_clear = true;
container->ready_to_draw = false;
@@ -329,6 +360,10 @@ void moz_container_realize(GtkWidget *wi
: gtk_widget_get_visual(widget);
window = gdk_window_new(parent, &attributes, attributes_mask);
+
+
+
+
gdk_window_set_user_data(window, widget);
} else {
window = parent;
@@ -498,6 +533,7 @@ static void moz_container_add(GtkContain
struct wl_surface *moz_container_get_wl_surface(MozContainer *container) {
if (!container->surface) {
if (!container->ready_to_draw) {
+ moz_container_request_parent_frame_callback(container);
return nullptr;
}
GdkDisplay *display = gtk_widget_get_display(GTK_WIDGET(container));
diff -up firefox-67.0/widget/gtk/mozcontainer.h.mozilla-1535567 firefox-67.0/widget/gtk/mozcontainer.h
--- firefox-67.0/widget/gtk/mozcontainer.h.mozilla-1535567 2019-05-14 01:08:37.000000000 +0200
+++ firefox-67.0/widget/gtk/mozcontainer.h 2019-05-15 15:50:59.440570372 +0200
@@ -77,6 +77,7 @@ struct _MozContainer {
struct wl_subsurface *subsurface;
struct wl_egl_window *eglwindow;
struct wl_callback *frame_callback_handler;
+ int frame_callback_handler_surface_id;
gboolean surface_needs_clear;
gboolean ready_to_draw;
std::function<void(void)> inital_draw_cb;

View File

@ -1,206 +0,0 @@
diff -up firefox-66.0.1/widget/gtk/nsWindow.cpp.mozilla-1539471 firefox-66.0.1/widget/gtk/nsWindow.cpp
--- firefox-66.0.1/widget/gtk/nsWindow.cpp.mozilla-1539471 2019-03-28 14:08:42.351128620 +0100
+++ firefox-66.0.1/widget/gtk/nsWindow.cpp 2019-03-28 14:20:23.282890178 +0100
@@ -312,6 +312,9 @@ static nsWindow *gFocusWindow = nullptr;
static bool gBlockActivateEvent = false;
static bool gGlobalsInitialized = false;
static bool gRaiseWindows = true;
+#ifdef MOZ_WAYLAND
+static GList *gCurrentPopupWindows = nullptr;
+#endif
#if GTK_CHECK_VERSION(3, 4, 0)
static uint32_t gLastTouchID = 0;
@@ -1136,8 +1139,16 @@ void nsWindow::NativeMoveResizeWaylandPo
return;
}
- GtkWidget* parentWidget =
- GTK_WIDGET(gtk_window_get_transient_for(GTK_WINDOW(mShell)));
+ GtkWidget *parentWidget;
+ if (mPopupType == ePopupTypeTooltip && gCurrentPopupWindows) {
+ // Attach tooltip window to the latest popup window
+ // to have both visible.
+ parentWidget = GTK_WIDGET(gCurrentPopupWindows->data);
+ gtk_window_set_transient_for(GTK_WINDOW(mShell),
+ GTK_WINDOW(parentWidget));
+ } else {
+ parentWidget = GTK_WIDGET(gtk_window_get_transient_for(GTK_WINDOW(mShell)));
+ }
int x_parent, y_parent;
gdk_window_get_origin(gtk_widget_get_window(parentWidget), &x_parent, &y_parent);
@@ -3489,7 +3500,7 @@ nsresult nsWindow::Create(nsIWidget *aPa
gtkTypeHint = GDK_WINDOW_TYPE_HINT_DND;
mIsDragPopup = true;
} else {
- switch (aInitData->mPopupHint) {
+ switch (mPopupType) {
case ePopupTypeMenu:
gtkTypeHint = GDK_WINDOW_TYPE_HINT_POPUP_MENU;
break;
@@ -3610,6 +3621,8 @@ nsresult nsWindow::Create(nsIWidget *aPa
return NS_ERROR_FAILURE;
case eWindowType_child: {
+ MOZ_ASSERT(mIsX11Display,
+ "eWindowType_child is not supported on Wayland!");
if (parentMozContainer) {
mGdkWindow = CreateGdkWindow(parentGdkWindow, parentMozContainer);
mHasMappedToplevel = parentnsWindow->mHasMappedToplevel;
@@ -3979,6 +3992,49 @@ void nsWindow::NativeMoveResize() {
}
}
+#ifdef MOZ_WAYLAND
+void nsWindow::OpenToplevelWaylandWindow() {
+ // Wayland keeps strong popup window hierarchy. We need to track active
+ // (visible) popup windows and make sure we hide popup on the same level
+ // before we open another one on that level. It means that every open
+ // popup needs to have an unique parent.
+ if (mWindowType == eWindowType_popup) {
+ GtkWidget *parentWidget =
+ GTK_WIDGET(gtk_window_get_transient_for(GTK_WINDOW(mShell)));
+
+ if (gCurrentPopupWindows) {
+ do {
+ GtkWidget *widget = GTK_WIDGET(gCurrentPopupWindows->data);
+ if (widget == parentWidget) {
+ break;
+ }
+ nsWindow* window = get_window_for_gtk_widget(widget);
+ NS_ASSERTION(window, "Unknown window in popup widget list!");
+ window->CloseToplevelWaylandWindow();
+
+ } while (gCurrentPopupWindows != nullptr);
+ }
+ gCurrentPopupWindows = g_list_prepend(gCurrentPopupWindows, mShell);
+ }
+
+ gtk_widget_show(mShell);
+}
+
+void nsWindow::CloseToplevelWaylandWindow() {
+ if (mContainer && moz_container_has_wl_egl_window(mContainer)) {
+ // Because wl_egl_window is destroyed on moz_container_unmap(),
+ // the current compositor cannot use it anymore. To avoid crash,
+ // destroy the compositor & recreate a new compositor on next
+ // expose event.
+ DestroyLayerManager();
+ }
+ if (mWindowType == eWindowType_popup) {
+ gCurrentPopupWindows = g_list_remove(gCurrentPopupWindows, mShell);
+ }
+ gtk_widget_hide(mShell);
+}
+#endif
+
void nsWindow::NativeShow(bool aAction) {
if (aAction) {
// unset our flag now that our window has been shown
@@ -3990,51 +4046,55 @@ void nsWindow::NativeShow(bool aAction)
SetUserTimeAndStartupIDForActivatedWindow(mShell);
}
- gtk_widget_show(mShell);
+#ifdef MOZ_WAYLAND
+ if (!mIsX11Display) {
+ OpenToplevelWaylandWindow();
+ } else
+#endif
+ {
+ gtk_widget_show(mShell);
+ }
} else if (mContainer) {
gtk_widget_show(GTK_WIDGET(mContainer));
} else if (mGdkWindow) {
gdk_window_show_unraised(mGdkWindow);
}
} else {
-#ifdef MOZ_WAYLAND
- if (mContainer && moz_container_has_wl_egl_window(mContainer)) {
- // Because wl_egl_window is destroyed on moz_container_unmap(),
- // the current compositor cannot use it anymore. To avoid crash,
- // destroy the compositor & recreate a new compositor on next
- // expose event.
- DestroyLayerManager();
- }
-#endif
-
if (mIsTopLevel) {
- // Workaround window freezes on GTK versions before 3.21.2 by
- // ensuring that configure events get dispatched to windows before
- // they are unmapped. See bug 1225044.
- if (gtk_check_version(3, 21, 2) != nullptr && mPendingConfigures > 0) {
- GtkAllocation allocation;
- gtk_widget_get_allocation(GTK_WIDGET(mShell), &allocation);
-
- GdkEventConfigure event;
- PodZero(&event);
- event.type = GDK_CONFIGURE;
- event.window = mGdkWindow;
- event.send_event = TRUE;
- event.x = allocation.x;
- event.y = allocation.y;
- event.width = allocation.width;
- event.height = allocation.height;
-
- auto shellClass = GTK_WIDGET_GET_CLASS(mShell);
- for (unsigned int i = 0; i < mPendingConfigures; i++) {
- Unused << shellClass->configure_event(mShell, &event);
+#ifdef MOZ_WAYLAND
+ if (!mIsX11Display) {
+ CloseToplevelWaylandWindow();
+ } else
+#endif
+ {
+ // Workaround window freezes on GTK versions before 3.21.2 by
+ // ensuring that configure events get dispatched to windows before
+ // they are unmapped. See bug 1225044.
+ if (gtk_check_version(3, 21, 2) != nullptr && mPendingConfigures > 0) {
+ GtkAllocation allocation;
+ gtk_widget_get_allocation(GTK_WIDGET(mShell), &allocation);
+
+ GdkEventConfigure event;
+ PodZero(&event);
+ event.type = GDK_CONFIGURE;
+ event.window = mGdkWindow;
+ event.send_event = TRUE;
+ event.x = allocation.x;
+ event.y = allocation.y;
+ event.width = allocation.width;
+ event.height = allocation.height;
+
+ auto shellClass = GTK_WIDGET_GET_CLASS(mShell);
+ for (unsigned int i = 0; i < mPendingConfigures; i++) {
+ Unused << shellClass->configure_event(mShell, &event);
+ }
+ mPendingConfigures = 0;
}
- mPendingConfigures = 0;
- }
- gtk_widget_hide(mShell);
+ gtk_widget_hide(mShell);
- ClearTransparencyBitmap(); // Release some resources
+ ClearTransparencyBitmap(); // Release some resources
+ }
} else if (mContainer) {
gtk_widget_hide(GTK_WIDGET(mContainer));
} else if (mGdkWindow) {
diff -up firefox-66.0.1/widget/gtk/nsWindow.h.mozilla-1539471 firefox-66.0.1/widget/gtk/nsWindow.h
--- firefox-66.0.1/widget/gtk/nsWindow.h.mozilla-1539471 2019-03-28 14:08:42.345128639 +0100
+++ firefox-66.0.1/widget/gtk/nsWindow.h 2019-03-28 14:08:42.355128607 +0100
@@ -603,6 +603,11 @@ class nsWindow final : public nsBaseWidg
void ForceTitlebarRedraw();
+#ifdef MOZ_WAYLAND
+ void OpenToplevelWaylandWindow();
+ void CloseToplevelWaylandWindow();
+#endif
+
/**
* |mIMContext| takes all IME related stuff.
*

View File

@ -1,156 +0,0 @@
diff -up firefox-67.0/toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp.mozilla-1540145 firefox-67.0/toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp
--- firefox-67.0/toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp.mozilla-1540145 2019-05-14 01:08:35.000000000 +0200
+++ firefox-67.0/toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp 2019-05-15 15:20:13.365502186 +0200
@@ -34,16 +34,10 @@ class nsUnixSystemProxySettings final :
private:
~nsUnixSystemProxySettings() = default;
- nsCOMPtr<nsIGConfService> mGConf;
- nsCOMPtr<nsIGSettingsService> mGSettings;
+ nsCOMPtr<nsIGSettingsService> mGSettings;
nsCOMPtr<nsIGSettingsCollection> mProxySettings;
nsInterfaceHashtable<nsCStringHashKey, nsIGSettingsCollection>
mSchemeProxySettings;
- bool IsProxyMode(const char* aMode);
- nsresult SetProxyResultFromGConf(const char* aKeyBase, const char* aType,
- nsACString& aResult);
- nsresult GetProxyFromGConf(const nsACString& aScheme, const nsACString& aHost,
- int32_t aPort, nsACString& aResult);
nsresult GetProxyFromGSettings(const nsACString& aScheme,
const nsACString& aHost, int32_t aPort,
nsACString& aResult);
@@ -68,16 +62,6 @@ void nsUnixSystemProxySettings::Init() {
NS_LITERAL_CSTRING("org.gnome.system.proxy"),
getter_AddRefs(mProxySettings));
}
- if (!mProxySettings) {
- mGConf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
- }
-}
-
-bool nsUnixSystemProxySettings::IsProxyMode(const char* aMode) {
- nsAutoCString mode;
- return NS_SUCCEEDED(mGConf->GetString(
- NS_LITERAL_CSTRING("/system/proxy/mode"), mode)) &&
- mode.EqualsASCII(aMode);
}
nsresult nsUnixSystemProxySettings::GetPACURI(nsACString& aResult) {
@@ -92,14 +76,8 @@ nsresult nsUnixSystemProxySettings::GetP
}
/* The org.gnome.system.proxy schema has been found, but auto mode is not
* set. Don't try the GConf and return empty string. */
- aResult.Truncate();
- return NS_OK;
}
- if (mGConf && IsProxyMode("auto")) {
- return mGConf->GetString(NS_LITERAL_CSTRING("/system/proxy/autoconfig_url"),
- aResult);
- }
// Return an empty string when auto mode is not set.
aResult.Truncate();
return NS_OK;
@@ -217,30 +195,6 @@ static nsresult GetProxyFromEnvironment(
return NS_OK;
}
-nsresult nsUnixSystemProxySettings::SetProxyResultFromGConf(
- const char* aKeyBase, const char* aType, nsACString& aResult) {
- nsAutoCString hostKey;
- hostKey.AppendASCII(aKeyBase);
- hostKey.AppendLiteral("host");
- nsAutoCString host;
- nsresult rv = mGConf->GetString(hostKey, host);
- NS_ENSURE_SUCCESS(rv, rv);
- if (host.IsEmpty()) return NS_ERROR_FAILURE;
-
- nsAutoCString portKey;
- portKey.AppendASCII(aKeyBase);
- portKey.AppendLiteral("port");
- int32_t port;
- rv = mGConf->GetInt(portKey, &port);
- NS_ENSURE_SUCCESS(rv, rv);
-
- /* When port is 0, proxy is not considered as enabled even if host is set. */
- if (port == 0) return NS_ERROR_FAILURE;
-
- SetProxyResult(aType, host, port, aResult);
- return NS_OK;
-}
-
nsresult nsUnixSystemProxySettings::SetProxyResultFromGSettings(
const char* aKeyBase, const char* aType, nsACString& aResult) {
nsDependentCString key(aKeyBase);
@@ -366,63 +320,6 @@ static bool HostIgnoredByProxy(const nsA
return memcmp(&ignoreAddr, &hostAddr, sizeof(PRIPv6Addr)) == 0;
}
-nsresult nsUnixSystemProxySettings::GetProxyFromGConf(const nsACString& aScheme,
- const nsACString& aHost,
- int32_t aPort,
- nsACString& aResult) {
- bool masterProxySwitch = false;
- mGConf->GetBool(NS_LITERAL_CSTRING("/system/http_proxy/use_http_proxy"),
- &masterProxySwitch);
- // if no proxy is set in GConf return NS_ERROR_FAILURE
- if (!(IsProxyMode("manual") || masterProxySwitch)) {
- return NS_ERROR_FAILURE;
- }
-
- nsCOMPtr<nsIArray> ignoreList;
- if (NS_SUCCEEDED(mGConf->GetStringList(
- NS_LITERAL_CSTRING("/system/http_proxy/ignore_hosts"),
- getter_AddRefs(ignoreList))) &&
- ignoreList) {
- uint32_t len = 0;
- ignoreList->GetLength(&len);
- for (uint32_t i = 0; i < len; ++i) {
- nsCOMPtr<nsISupportsString> str = do_QueryElementAt(ignoreList, i);
- if (str) {
- nsAutoString s;
- if (NS_SUCCEEDED(str->GetData(s)) && !s.IsEmpty()) {
- if (HostIgnoredByProxy(NS_ConvertUTF16toUTF8(s), aHost)) {
- aResult.AppendLiteral("DIRECT");
- return NS_OK;
- }
- }
- }
- }
- }
-
- bool useHttpProxyForAll = false;
- // This setting sometimes doesn't exist, don't bail on failure
- mGConf->GetBool(NS_LITERAL_CSTRING("/system/http_proxy/use_same_proxy"),
- &useHttpProxyForAll);
-
- nsresult rv;
- if (!useHttpProxyForAll) {
- rv = SetProxyResultFromGConf("/system/proxy/socks_", "SOCKS", aResult);
- if (NS_SUCCEEDED(rv)) return rv;
- }
-
- if (aScheme.LowerCaseEqualsLiteral("http") || useHttpProxyForAll) {
- rv = SetProxyResultFromGConf("/system/http_proxy/", "PROXY", aResult);
- } else if (aScheme.LowerCaseEqualsLiteral("https")) {
- rv = SetProxyResultFromGConf("/system/proxy/secure_", "PROXY", aResult);
- } else if (aScheme.LowerCaseEqualsLiteral("ftp")) {
- rv = SetProxyResultFromGConf("/system/proxy/ftp_", "PROXY", aResult);
- } else {
- rv = NS_ERROR_FAILURE;
- }
-
- return rv;
-}
-
nsresult nsUnixSystemProxySettings::GetProxyFromGSettings(
const nsACString& aScheme, const nsACString& aHost, int32_t aPort,
nsACString& aResult) {
@@ -494,7 +391,6 @@ nsresult nsUnixSystemProxySettings::GetP
nsresult rv = GetProxyFromGSettings(aScheme, aHost, aPort, aResult);
if (NS_SUCCEEDED(rv)) return rv;
}
- if (mGConf) return GetProxyFromGConf(aScheme, aHost, aPort, aResult);
return GetProxyFromEnvironment(aScheme, aHost, aPort, aResult);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,3 @@
SHA512 (cbindgen-vendor.tar.xz) = bdd1535c9923a082cdca263ff2c1765814b00b6a1c74be95bac4dbf7d0b7b29c1c27f0fed6feae99c88521c96e2865f0ea3cf784bd9a32a44cec6ee4df850662
SHA512 (firefox-67.0.4.source.tar.xz) = 42abc837b5808a55e68273db6aa45fa73f8fe1df3c9072c94d8d049b6803ce8758745cc0a68af64c4ce9f86e5dd3b3619824ba67fabddce428204605894d9ee7
SHA512 (firefox-langpacks-67.0.4-20190620.tar.xz) = 99a0528d7be28a26352dc43ef0090b38a83959af2b68d9b08015c83f523bbc9f364199a9016d13b5a039a2d8aaa164f8b4b0a210d0c62d209d5261dbfa9ada1f
SHA512 (firefox-68.0.source.tar.xz) = 3822d9e72edffd278b4a8e86998252e7e7134a1751d64c9913e5492971f41606187b67b3639dcfca6c97ae958547d6bc0426a5cb2c321e32fb96f33ed8760feb
SHA512 (firefox-langpacks-68.0-20190702.tar.xz) = 6b146f7ef5fd57c38d3074b5f7ee19ac90d11d3e742bedb843f47ed528c27df8aa3f38698e31dd0357cdfa13e37a08845c29e5b5ac0efe8c8291b2272acae1d7