Bug 1661450 - 2/8 Add wayland required code getting opt-out by disabling MOZ_X11 r=stransky,rmader

Ensure shared code with MOZ_X11 and MOZ_WAYLAND remains when MOZ_X11 is
undefined

Depends on D139526

Differential Revision: https://phabricator.services.mozilla.com/D139528
This commit is contained in:
ganguin 2022-04-20 09:32:07 +00:00
parent fc2a921247
commit f01acfd647
8 changed files with 56 additions and 61 deletions

View file

@ -75,9 +75,11 @@
#include "mozilla/dom/DOMRect.h" #include "mozilla/dom/DOMRect.h"
#include <algorithm> #include <algorithm>
#if defined(MOZ_X11) && defined(MOZ_WIDGET_GTK) #if defined(MOZ_WIDGET_GTK)
# include <gdk/gdk.h> # include <gdk/gdk.h>
# if defined(MOZ_X11)
# include <gdk/gdkx.h> # include <gdk/gdkx.h>
# endif
#endif #endif
#include "Layers.h" #include "Layers.h"

View file

@ -55,8 +55,10 @@
#define CAIRO_HAS_PDF_SURFACE 1 #define CAIRO_HAS_PDF_SURFACE 1
#endif #endif
#ifdef MOZ_X11 #if defined(MOZ_X11) || defined(MOZ_WAYLAND)
#define CAIRO_HAS_PS_SURFACE 1 #define CAIRO_HAS_PS_SURFACE 1
#endif
#ifdef MOZ_X11
#define CAIRO_HAS_XLIB_XRENDER_SURFACE 0 #define CAIRO_HAS_XLIB_XRENDER_SURFACE 0
#define CAIRO_HAS_XLIB_SURFACE 1 #define CAIRO_HAS_XLIB_SURFACE 1
#endif #endif

View file

@ -325,7 +325,6 @@ already_AddRefed<gfxASurface> gfxPlatformGtk::CreateOffscreenSurface(
RefPtr<gfxASurface> newSurface; RefPtr<gfxASurface> newSurface;
bool needsClear = true; bool needsClear = true;
#ifdef MOZ_X11
// XXX we really need a different interface here, something that passes // XXX we really need a different interface here, something that passes
// in more context, including the display and/or target surface type that // in more context, including the display and/or target surface type that
// we should try to match // we should try to match
@ -336,7 +335,6 @@ already_AddRefed<gfxASurface> gfxPlatformGtk::CreateOffscreenSurface(
// waste time clearing again // waste time clearing again
needsClear = false; needsClear = false;
} }
#endif
if (!newSurface) { if (!newSurface) {
// We couldn't create a native surface for whatever reason; // We couldn't create a native surface for whatever reason;
@ -951,8 +949,10 @@ class XrandrSoftwareVsyncSource final : public SoftwareVsyncSource {
return rate; return rate;
} }
}; };
#endif
already_AddRefed<gfx::VsyncSource> gfxPlatformGtk::CreateHardwareVsyncSource() { already_AddRefed<gfx::VsyncSource> gfxPlatformGtk::CreateHardwareVsyncSource() {
#ifdef MOZ_X11
if (IsHeadless() || IsWaylandDisplay()) { if (IsHeadless() || IsWaylandDisplay()) {
// On Wayland we can not create a global hardware based vsync source, thus // On Wayland we can not create a global hardware based vsync source, thus
// use a software based one here. We create window specific ones later. // use a software based one here. We create window specific ones later.
@ -988,8 +988,10 @@ already_AddRefed<gfx::VsyncSource> gfxPlatformGtk::CreateHardwareVsyncSource() {
RefPtr<VsyncSource> softwareVsync = new XrandrSoftwareVsyncSource(); RefPtr<VsyncSource> softwareVsync = new XrandrSoftwareVsyncSource();
return softwareVsync.forget(); return softwareVsync.forget();
} #else
return gfxPlatform::CreateHardwareVsyncSource();
#endif #endif
}
void gfxPlatformGtk::BuildContentDeviceData(ContentDeviceData* aOut) { void gfxPlatformGtk::BuildContentDeviceData(ContentDeviceData* aOut) {
gfxPlatform::BuildContentDeviceData(aOut); gfxPlatform::BuildContentDeviceData(aOut);

View file

@ -55,10 +55,8 @@ class gfxPlatformGtk final : public gfxPlatform {
bool AccelerateLayersByDefault() override; bool AccelerateLayersByDefault() override;
#ifdef MOZ_X11
already_AddRefed<mozilla::gfx::VsyncSource> CreateHardwareVsyncSource() already_AddRefed<mozilla::gfx::VsyncSource> CreateHardwareVsyncSource()
override; override;
#endif
bool IsX11Display() { return mIsX11Display; } bool IsX11Display() { return mIsX11Display; }
bool IsWaylandDisplay() override { bool IsWaylandDisplay() override {

View file

@ -62,7 +62,8 @@ class CompositorWidgetDelegate {
}; };
// Platforms that support out-of-process widgets. // Platforms that support out-of-process widgets.
#if defined(XP_WIN) || defined(MOZ_X11) || defined(MOZ_WIDGET_ANDROID) #if defined(XP_WIN) || defined(MOZ_X11) || defined(MOZ_WIDGET_ANDROID) || \
defined(MOZ_WAYLAND)
// CompositorWidgetParent should implement CompositorWidget and // CompositorWidgetParent should implement CompositorWidget and
// PCompositorWidgetParent. // PCompositorWidgetParent.
class CompositorWidgetParent; class CompositorWidgetParent;

View file

@ -33,7 +33,6 @@ TaskbarProgress::~TaskbarProgress() {
NS_IMETHODIMP NS_IMETHODIMP
TaskbarProgress::SetProgressState(nsTaskbarProgressState aState, TaskbarProgress::SetProgressState(nsTaskbarProgressState aState,
uint64_t aCurrentValue, uint64_t aMaxValue) { uint64_t aCurrentValue, uint64_t aMaxValue) {
#ifdef MOZ_X11
NS_ENSURE_ARG_RANGE(aState, 0, STATE_PAUSED); NS_ENSURE_ARG_RANGE(aState, 0, STATE_PAUSED);
if (aState == STATE_NO_PROGRESS || aState == STATE_INDETERMINATE) { if (aState == STATE_NO_PROGRESS || aState == STATE_INDETERMINATE) {
@ -72,7 +71,6 @@ TaskbarProgress::SetProgressState(nsTaskbarProgressState aState,
("GtkTaskbarProgress::SetProgressState progress: %lu", progress)); ("GtkTaskbarProgress::SetProgressState progress: %lu", progress));
mPrimaryWindow->SetProgress(progress); mPrimaryWindow->SetProgress(progress);
#endif
return NS_OK; return NS_OK;
} }

View file

@ -76,10 +76,6 @@ Classes = [
'headers': ['/widget/gtk/nsApplicationChooser.h'], 'headers': ['/widget/gtk/nsApplicationChooser.h'],
'processes': ProcessSelector.MAIN_PROCESS_ONLY, 'processes': ProcessSelector.MAIN_PROCESS_ONLY,
}, },
]
if defined('MOZ_X11'):
Classes += [
{ {
'js_name': 'clipboard', 'js_name': 'clipboard',
'cid': '{8b5314ba-db01-11d2-96ce-0060b0fb9956}', 'cid': '{8b5314ba-db01-11d2-96ce-0060b0fb9956}',
@ -121,7 +117,7 @@ if defined('MOZ_X11'):
'headers': ['/widget/gtk/nsUserIdleServiceGTK.h'], 'headers': ['/widget/gtk/nsUserIdleServiceGTK.h'],
'constructor': 'nsUserIdleServiceGTK::GetInstance', 'constructor': 'nsUserIdleServiceGTK::GetInstance',
}, },
] ]
if defined('NS_PRINTING'): if defined('NS_PRINTING'):
Classes += [ Classes += [

View file

@ -20,9 +20,7 @@
#include "nsHTMLFormatConverter.h" #include "nsHTMLFormatConverter.h"
#include "HeadlessClipboard.h" #include "HeadlessClipboard.h"
#include "IMContextWrapper.h" #include "IMContextWrapper.h"
#ifdef MOZ_X11 #include "nsClipboard.h"
# include "nsClipboard.h"
#endif
#include "TaskbarProgress.h" #include "TaskbarProgress.h"
#include "nsFilePicker.h" #include "nsFilePicker.h"
#include "nsSound.h" #include "nsSound.h"
@ -36,7 +34,6 @@
using namespace mozilla; using namespace mozilla;
using namespace mozilla::widget; using namespace mozilla::widget;
#ifdef MOZ_X11
NS_IMPL_COMPONENT_FACTORY(nsIClipboard) { NS_IMPL_COMPONENT_FACTORY(nsIClipboard) {
nsCOMPtr<nsIClipboard> inst; nsCOMPtr<nsIClipboard> inst;
if (gfxPlatform::IsHeadless()) { if (gfxPlatform::IsHeadless()) {
@ -51,7 +48,6 @@ NS_IMPL_COMPONENT_FACTORY(nsIClipboard) {
return inst.forget().downcast<nsISupports>(); return inst.forget().downcast<nsISupports>();
} }
#endif
nsresult nsWidgetGtk2ModuleCtor() { return nsAppShellInit(); } nsresult nsWidgetGtk2ModuleCtor() { return nsAppShellInit(); }