# HG changeset patch
# Parent  68932e4ec76114a9816c6726c6a99964cbc9568b

diff --git a/config/system-headers.mozbuild b/config/system-headers.mozbuild
--- a/config/system-headers.mozbuild
+++ b/config/system-headers.mozbuild
@@ -1016,18 +1016,16 @@ system_headers = [
     'wx/log.h',
     'wx/toolbar.h',
     'wx/wx.h',
     'wx/xrc/xmlres.h',
     'X11/cursorfont.h',
     'X11/extensions/Print.h',
     'X11/extensions/scrnsaver.h',
     'X11/extensions/shape.h',
-    'X11/extensions/Xcomposite.h',
-    'X11/extensions/Xdamage.h',
     'X11/extensions/Xfixes.h',
     'X11/extensions/Xrender.h',
     'X11/extensions/XShm.h',
     'X11/ImUtil.h',
     'X11/Intrinsic.h',
     'X11/keysymdef.h',
     'X11/keysym.h',
     'X11/Shell.h',
diff --git a/js/src/threading/posix/PosixThread.cpp b/js/src/threading/posix/PosixThread.cpp
--- a/js/src/threading/posix/PosixThread.cpp
+++ b/js/src/threading/posix/PosixThread.cpp
@@ -99,17 +99,18 @@ void ThisThread::SetName(const char* nam
 #ifdef XP_DARWIN
   rv = pthread_setname_np(name);
 #elif defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
   pthread_set_name_np(pthread_self(), name);
   rv = 0;
 #elif defined(__NetBSD__)
   rv = pthread_setname_np(pthread_self(), "%s", (void*)name);
 #else
-  rv = pthread_setname_np(pthread_self(), name);
+//  rv = pthread_setname_np(pthread_self(), name);
+    rv = 0;
 #endif
   MOZ_RELEASE_ASSERT(!rv);
 }
 
 void ThisThread::GetName(char* nameBuffer, size_t len) {
   MOZ_RELEASE_ASSERT(len >= 16);
 
   int rv = -1;
diff --git a/media/webrtc/gn-configs/x64_False_x64_linux.json b/media/webrtc/gn-configs/x64_False_x64_linux.json
--- a/media/webrtc/gn-configs/x64_False_x64_linux.json
+++ b/media/webrtc/gn-configs/x64_False_x64_linux.json
@@ -138,19 +138,17 @@
                 "//modules/audio_device/dummy/"
             ],
             "libs": [
                 "rt",
                 "m",
                 "X11",
                 "X11-xcb",
                 "xcb",
-                "Xcomposite",
                 "Xcursor",
-                "Xdamage",
                 "Xext",
                 "Xfixes",
                 "Xi",
                 "Xrender"
             ],
             "sources": [],
             "type": "static_library"
         },
@@ -10644,19 +10642,17 @@
             "include_dirs": [
                 "//",
                 "/home/dminor/src/firefox-branchupdate/objdir-ff-asan/media/webrtc/trunk/webrtc/gn-output/gen/"
             ],
             "libs": [
                 "X11",
                 "X11-xcb",
                 "xcb",
-                "Xcomposite",
                 "Xcursor",
-                "Xdamage",
                 "Xext",
                 "Xfixes",
                 "Xi",
                 "Xrender",
                 "rt"
             ],
             "sources": [],
             "type": "source_set"
@@ -10856,19 +10852,17 @@
                 "/media/libyuv/libyuv/include/",
                 "//",
                 "/home/dminor/src/firefox-branchupdate/objdir-ff-asan/media/webrtc/trunk/webrtc/gn-output/gen/"
             ],
             "libs": [
                 "X11",
                 "X11-xcb",
                 "xcb",
-                "Xcomposite",
                 "Xcursor",
-                "Xdamage",
                 "Xext",
                 "Xfixes",
                 "Xi",
                 "Xrender",
                 "rt"
             ],
             "sources": [
                 "//modules/desktop_capture/blank_detector_desktop_capturer_wrapper.cc",
diff --git a/media/webrtc/gn-configs/x64_False_x86_linux.json b/media/webrtc/gn-configs/x64_False_x86_linux.json
--- a/media/webrtc/gn-configs/x64_False_x86_linux.json
+++ b/media/webrtc/gn-configs/x64_False_x86_linux.json
@@ -144,19 +144,17 @@
                 "//modules/audio_device/dummy/"
             ],
             "libs": [
                 "rt",
                 "m",
                 "X11",
                 "X11-xcb",
                 "xcb",
-                "Xcomposite",
                 "Xcursor",
-                "Xdamage",
                 "Xext",
                 "Xfixes",
                 "Xi",
                 "Xrender"
             ],
             "sources": [],
             "type": "static_library"
         },
@@ -11212,19 +11210,17 @@
             "include_dirs": [
                 "//",
                 "/home/cmanchester/m-c/obj-dbg/media/webrtc/trunk/webrtc/gn-output/gen/"
             ],
             "libs": [
                 "X11",
                 "X11-xcb",
                 "xcb",
-                "Xcomposite",
                 "Xcursor",
-                "Xdamage",
                 "Xext",
                 "Xfixes",
                 "Xi",
                 "Xrender",
                 "rt"
             ],
             "sources": [],
             "type": "source_set"
@@ -11435,19 +11431,17 @@
                 "/media/libyuv/libyuv/include/",
                 "//",
                 "/home/cmanchester/m-c/obj-dbg/media/webrtc/trunk/webrtc/gn-output/gen/"
             ],
             "libs": [
                 "X11",
                 "X11-xcb",
                 "xcb",
-                "Xcomposite",
                 "Xcursor",
-                "Xdamage",
                 "Xext",
                 "Xfixes",
                 "Xi",
                 "Xrender",
                 "rt"
             ],
             "sources": [
                 "//modules/desktop_capture/blank_detector_desktop_capturer_wrapper.cc",
diff --git a/media/webrtc/gn-configs/x64_True_x64_linux.json b/media/webrtc/gn-configs/x64_True_x64_linux.json
--- a/media/webrtc/gn-configs/x64_True_x64_linux.json
+++ b/media/webrtc/gn-configs/x64_True_x64_linux.json
@@ -135,19 +135,17 @@
                 "//modules/audio_device/dummy/"
             ],
             "libs": [
                 "rt",
                 "m",
                 "X11",
                 "X11-xcb",
                 "xcb",
-                "Xcomposite",
                 "Xcursor",
-                "Xdamage",
                 "Xext",
                 "Xfixes",
                 "Xi",
                 "Xrender"
             ],
             "sources": [],
             "type": "static_library"
         },
@@ -10359,19 +10357,17 @@
             "include_dirs": [
                 "//",
                 "/home/dminor/src/firefox-branchupdate/objdir-ff-asan/media/webrtc/trunk/webrtc/gn-output/gen/"
             ],
             "libs": [
                 "X11",
                 "X11-xcb",
                 "xcb",
-                "Xcomposite",
                 "Xcursor",
-                "Xdamage",
                 "Xext",
                 "Xfixes",
                 "Xi",
                 "Xrender",
                 "rt"
             ],
             "sources": [],
             "type": "source_set"
@@ -10565,19 +10561,17 @@
                 "/media/libyuv/libyuv/include/",
                 "//",
                 "/home/dminor/src/firefox-branchupdate/objdir-ff-asan/media/webrtc/trunk/webrtc/gn-output/gen/"
             ],
             "libs": [
                 "X11",
                 "X11-xcb",
                 "xcb",
-                "Xcomposite",
                 "Xcursor",
-                "Xdamage",
                 "Xext",
                 "Xfixes",
                 "Xi",
                 "Xrender",
                 "rt"
             ],
             "sources": [
                 "//modules/desktop_capture/blank_detector_desktop_capturer_wrapper.cc",
diff --git a/media/webrtc/gn-configs/x64_True_x86_linux.json b/media/webrtc/gn-configs/x64_True_x86_linux.json
--- a/media/webrtc/gn-configs/x64_True_x86_linux.json
+++ b/media/webrtc/gn-configs/x64_True_x86_linux.json
@@ -141,19 +141,17 @@
                 "//modules/audio_device/dummy/"
             ],
             "libs": [
                 "rt",
                 "m",
                 "X11",
                 "X11-xcb",
                 "xcb",
-                "Xcomposite",
                 "Xcursor",
-                "Xdamage",
                 "Xext",
                 "Xfixes",
                 "Xi",
                 "Xrender"
             ],
             "sources": [],
             "type": "static_library"
         },
@@ -10927,19 +10925,17 @@
             "include_dirs": [
                 "//",
                 "/home/cmanchester/m-c/obj-dbg/media/webrtc/trunk/webrtc/gn-output/gen/"
             ],
             "libs": [
                 "X11",
                 "X11-xcb",
                 "xcb",
-                "Xcomposite",
                 "Xcursor",
-                "Xdamage",
                 "Xext",
                 "Xfixes",
                 "Xi",
                 "Xrender",
                 "rt"
             ],
             "sources": [],
             "type": "source_set"
@@ -11144,19 +11140,17 @@
                 "/media/libyuv/libyuv/include/",
                 "//",
                 "/home/cmanchester/m-c/obj-dbg/media/webrtc/trunk/webrtc/gn-output/gen/"
             ],
             "libs": [
                 "X11",
                 "X11-xcb",
                 "xcb",
-                "Xcomposite",
                 "Xcursor",
-                "Xdamage",
                 "Xext",
                 "Xfixes",
                 "Xi",
                 "Xrender",
                 "rt"
             ],
             "sources": [
                 "//modules/desktop_capture/blank_detector_desktop_capturer_wrapper.cc",
diff --git a/media/webrtc/trunk/webrtc/build/config/linux/BUILD.gn b/media/webrtc/trunk/webrtc/build/config/linux/BUILD.gn
--- a/media/webrtc/trunk/webrtc/build/config/linux/BUILD.gn
+++ b/media/webrtc/trunk/webrtc/build/config/linux/BUILD.gn
@@ -27,36 +27,30 @@ config("runtime_library") {
   }
 }
 
 config("x11") {
   libs = [
     "X11",
     "X11-xcb",
     "xcb",
-    "Xcomposite",
     "Xcursor",
-    "Xdamage",
     "Xext",
     "Xfixes",
     "Xi",
     "Xrender",
   ]
 
   if (!build_with_mozilla) {
     libs += [
       "Xtst",
     ]
   }
 }
 
-config("xcomposite") {
-  libs = [ "Xcomposite" ]
-}
-
 config("xext") {
   libs = [ "Xext" ]
 }
 
 config("xrandr") {
   libs = [ "Xrandr" ]
 }
 
diff --git a/media/webrtc/trunk/webrtc/build/experimental/install-build-deps.py b/media/webrtc/trunk/webrtc/build/experimental/install-build-deps.py
--- a/media/webrtc/trunk/webrtc/build/experimental/install-build-deps.py
+++ b/media/webrtc/trunk/webrtc/build/experimental/install-build-deps.py
@@ -135,19 +135,17 @@ SUPPORTED_UBUNTU_VERSIONS = (
   'libpng12-0',
   'libspeechd2',
   'libsqlite3-0',
   'libstdc++6',
   'libx11-6',
   'libx11-xcb1',
   'libxau6',
   'libxcb1',
-  'libxcomposite1',
   'libxcursor1',
-  'libxdamage1',
   'libxdmcp6',
   'libxext6',
   'libxfixes3',
   'libxi6',
   'libxinerama1',
   'libxrandr2',
   'libxrender1',
   'libxtst6',
@@ -166,19 +164,17 @@ SUPPORTED_UBUNTU_VERSIONS = (
   'libpango1.0-0-dbg',
   'libpcre3-dbg',
   'libpixman-1-0-dbg',
   'libsqlite3-0-dbg',
   'libx11-6-dbg',
   'libx11-xcb1-dbg',
   'libxau6-dbg',
   'libxcb1-dbg',
-  'libxcomposite1-dbg',
   'libxcursor1-dbg',
-  'libxdamage1-dbg',
   'libxdmcp6-dbg',
   'libxext6-dbg',
   'libxfixes3-dbg',
   'libxi6-dbg',
   'libxinerama1-dbg',
   'libxrandr2-dbg',
   'libxrender1-dbg',
   'libxtst6-dbg',
@@ -225,19 +221,17 @@ SUPPORTED_UBUNTU_VERSIONS = (
   'libgtk2.0-0:i386',
   'libncurses5:i386',
   'libnss3:i386',
   'libpango1.0-0:i386',
   'libssl1.0.0:i386',
   'libtinfo-dev',
   'libtinfo-dev:i386',
   'libtool',
-  'libxcomposite1:i386',
   'libxcursor1:i386',
-  'libxdamage1:i386',
   'libxi6:i386',
   'libxrandr2:i386',
   'libxss1:i386',
   'libxtst6:i386',
   'texinfo',
   'xvfb',
 )
 
diff --git a/media/webrtc/trunk/webrtc/build/install-build-deps.sh b/media/webrtc/trunk/webrtc/build/install-build-deps.sh
--- a/media/webrtc/trunk/webrtc/build/install-build-deps.sh
+++ b/media/webrtc/trunk/webrtc/build/install-build-deps.sh
@@ -244,19 +244,17 @@ lib_list="\
   libpixman-1-0
   libspeechd2
   libstdc++6
   libsqlite3-0
   libx11-6
   libx11-xcb1
   libxau6
   libxcb1
-  libxcomposite1
   libxcursor1
-  libxdamage1
   libxdmcp6
   libxext6
   libxfixes3
   libxi6
   libxinerama1
   libxrandr2
   libxrender1
   libxtst6
@@ -277,19 +275,17 @@ dbg_list="\
   libpango1.0-0-dbg
   libpcre3-dbg
   libpixman-1-0-dbg
   libsqlite3-0-dbg
   libx11-6-dbg
   libx11-xcb1-dbg
   libxau6-dbg
   libxcb1-dbg
-  libxcomposite1-dbg
   libxcursor1-dbg
-  libxdamage1-dbg
   libxdmcp6-dbg
   libxext6-dbg
   libxi6-dbg
   libxinerama1-dbg
   libxrandr2-dbg
   libxrender1-dbg
   libxtst6-dbg
   zlib1g-dbg
@@ -383,19 +379,17 @@ nacl_list="\
   libncurses5:i386
   lib32ncurses5-dev
   libnss3:i386
   libpango1.0-0:i386
   libssl-dev:i386
   libtinfo-dev
   libtinfo-dev:i386
   libtool
-  libxcomposite1:i386
   libxcursor1:i386
-  libxdamage1:i386
   libxi6:i386
   libxrandr2:i386
   libxss1:i386
   libxtst6:i386
   texinfo
   xvfb
   ${naclports_list}
 "
diff --git a/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_gn/moz.build b/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_gn/moz.build
--- a/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_gn/moz.build
+++ b/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_gn/moz.build
@@ -58,19 +58,17 @@ if CONFIG["OS_TARGET"] == "DragonFly":
     DEFINES["WEBRTC_BSD"] = True
     DEFINES["WEBRTC_POSIX"] = True
     DEFINES["_FILE_OFFSET_BITS"] = "64"
 
     OS_LIBS += [
         "X11",
         "X11-xcb",
         "xcb",
-        "Xcomposite",
         "Xcursor",
-        "Xdamage",
         "Xext",
         "Xfixes",
         "Xi",
         "Xrender"
     ]
 
 if CONFIG["OS_TARGET"] == "FreeBSD":
 
@@ -78,19 +76,17 @@ if CONFIG["OS_TARGET"] == "FreeBSD":
     DEFINES["WEBRTC_BSD"] = True
     DEFINES["WEBRTC_POSIX"] = True
     DEFINES["_FILE_OFFSET_BITS"] = "64"
 
     OS_LIBS += [
         "X11",
         "X11-xcb",
         "xcb",
-        "Xcomposite",
         "Xcursor",
-        "Xdamage",
         "Xext",
         "Xfixes",
         "Xi",
         "Xrender"
     ]
 
 if CONFIG["OS_TARGET"] == "Linux":
 
@@ -100,19 +96,17 @@ if CONFIG["OS_TARGET"] == "Linux":
     DEFINES["WEBRTC_POSIX"] = True
     DEFINES["_FILE_OFFSET_BITS"] = "64"
 
     OS_LIBS += [
         "rt",
         "X11",
         "X11-xcb",
         "xcb",
-        "Xcomposite",
         "Xcursor",
-        "Xdamage",
         "Xext",
         "Xfixes",
         "Xi",
         "Xrender"
     ]
 
 if CONFIG["OS_TARGET"] == "NetBSD":
 
@@ -120,19 +114,17 @@ if CONFIG["OS_TARGET"] == "NetBSD":
     DEFINES["WEBRTC_BSD"] = True
     DEFINES["WEBRTC_POSIX"] = True
     DEFINES["_FILE_OFFSET_BITS"] = "64"
 
     OS_LIBS += [
         "X11",
         "X11-xcb",
         "xcb",
-        "Xcomposite",
         "Xcursor",
-        "Xdamage",
         "Xext",
         "Xfixes",
         "Xi",
         "Xrender"
     ]
 
 if CONFIG["OS_TARGET"] == "OpenBSD":
 
@@ -140,19 +132,17 @@ if CONFIG["OS_TARGET"] == "OpenBSD":
     DEFINES["WEBRTC_BSD"] = True
     DEFINES["WEBRTC_POSIX"] = True
     DEFINES["_FILE_OFFSET_BITS"] = "64"
 
     OS_LIBS += [
         "X11",
         "X11-xcb",
         "xcb",
-        "Xcomposite",
         "Xcursor",
-        "Xdamage",
         "Xext",
         "Xfixes",
         "Xi",
         "Xrender"
     ]
 
 if CONFIG["OS_TARGET"] == "WINNT":
 
diff --git a/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/screen_capturer_x11.cc b/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/screen_capturer_x11.cc
--- a/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/screen_capturer_x11.cc
+++ b/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/screen_capturer_x11.cc
@@ -7,17 +7,16 @@
  *  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/linux/screen_capturer_x11.h"
 
 #include <string.h>
 
-#include <X11/extensions/Xdamage.h>
 #include <X11/extensions/Xfixes.h>
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
 
 #include <memory>
 #include <set>
 #include <utility>
 
@@ -35,20 +34,16 @@
 namespace webrtc {
 
 ScreenCapturerX11::ScreenCapturerX11() {
   helper_.SetLogGridSize(4);
 }
 
 ScreenCapturerX11::~ScreenCapturerX11() {
   options_.x_display()->RemoveEventHandler(ConfigureNotify, this);
-  if (use_damage_) {
-    options_.x_display()->RemoveEventHandler(
-        damage_event_base_ + XDamageNotify, this);
-  }
   DeinitXlib();
 }
 
 bool ScreenCapturerX11::Init(const DesktopCaptureOptions& options) {
   options_ = options;
 
   root_window_ = RootWindow(display(), DefaultScreen(display()));
   if (root_window_ == BadValue) {
@@ -91,49 +86,17 @@ bool ScreenCapturerX11::Init(const Deskt
 }
 
 void ScreenCapturerX11::InitXDamage() {
   // Our use of XDamage requires XFixes.
   if (!has_xfixes_) {
     return;
   }
 
-  // Check for XDamage extension.
-  if (!XDamageQueryExtension(display(), &damage_event_base_,
-                             &damage_error_base_)) {
-    RTC_LOG(LS_INFO) << "X server does not support XDamage.";
-    return;
-  }
-
-  // TODO(lambroslambrou): Disable DAMAGE in situations where it is known
-  // to fail, such as when Desktop Effects are enabled, with graphics
-  // drivers (nVidia, ATI) that fail to report DAMAGE notifications
-  // properly.
-
-  // Request notifications every time the screen becomes damaged.
-  damage_handle_ = XDamageCreate(display(), root_window_,
-                                 XDamageReportNonEmpty);
-  if (!damage_handle_) {
-    RTC_LOG(LS_ERROR) << "Unable to initialize XDamage.";
-    return;
-  }
-
-  // Create an XFixes server-side region to collate damage into.
-  damage_region_ = XFixesCreateRegion(display(), 0, 0);
-  if (!damage_region_) {
-    XDamageDestroy(display(), damage_handle_);
-    RTC_LOG(LS_ERROR) << "Unable to create XFixes region.";
-    return;
-  }
-
-  options_.x_display()->AddEventHandler(
-      damage_event_base_ + XDamageNotify, this);
-
-  use_damage_ = true;
-  RTC_LOG(LS_INFO) << "Using XDamage extension.";
+  RTC_LOG(LS_INFO) << "X server does not support XDamage extension.";
 }
 
 void ScreenCapturerX11::Start(Callback* callback) {
   RTC_DCHECK(!callback_);
   RTC_DCHECK(callback);
 
   callback_ = callback;
 }
@@ -185,24 +148,17 @@ bool ScreenCapturerX11::GetSourceList(So
 }
 
 bool ScreenCapturerX11::SelectSource(SourceId id) {
   // TODO(jiayl): implement screen selection.
   return true;
 }
 
 bool ScreenCapturerX11::HandleXEvent(const XEvent& event) {
-  if (use_damage_ && (event.type == damage_event_base_ + XDamageNotify)) {
-    const XDamageNotifyEvent* damage_event =
-        reinterpret_cast<const XDamageNotifyEvent*>(&event);
-    if (damage_event->damage != damage_handle_)
-      return false;
-    RTC_DCHECK(damage_event->level == XDamageReportNonEmpty);
-    return true;
-  } else if (event.type == ConfigureNotify) {
+  if (event.type == ConfigureNotify) {
     ScreenConfigurationChanged();
     return true;
   }
   return false;
 }
 
 std::unique_ptr<DesktopFrame> ScreenCapturerX11::CaptureScreen() {
   std::unique_ptr<SharedDesktopFrame> frame = queue_.current_frame()->Share();
@@ -211,51 +167,21 @@ std::unique_ptr<DesktopFrame> ScreenCapt
   // Pass the screen size to the helper, so it can clip the invalid region if it
   // expands that region to a grid.
   helper_.set_size_most_recent(frame->size());
 
   // In the DAMAGE case, ensure the frame is up-to-date with the previous frame
   // if any.  If there isn't a previous frame, that means a screen-resolution
   // change occurred, and |invalid_rects| will be updated to include the whole
   // screen.
-  if (use_damage_ && queue_.previous_frame())
-    SynchronizeFrame();
 
   DesktopRegion* updated_region = frame->mutable_updated_region();
 
   x_server_pixel_buffer_.Synchronize();
-  if (use_damage_ && queue_.previous_frame()) {
-    // Atomically fetch and clear the damage region.
-    XDamageSubtract(display(), damage_handle_, None, damage_region_);
-    int rects_num = 0;
-    XRectangle bounds;
-    XRectangle* rects = XFixesFetchRegionAndBounds(display(), damage_region_,
-                                                   &rects_num, &bounds);
-    for (int i = 0; i < rects_num; ++i) {
-      updated_region->AddRect(DesktopRect::MakeXYWH(
-          rects[i].x, rects[i].y, rects[i].width, rects[i].height));
-    }
-    XFree(rects);
-    helper_.InvalidateRegion(*updated_region);
-
-    // Capture the damaged portions of the desktop.
-    helper_.TakeInvalidRegion(updated_region);
-
-    // Clip the damaged portions to the current screen size, just in case some
-    // spurious XDamage notifications were received for a previous (larger)
-    // screen size.
-    updated_region->IntersectWith(
-        DesktopRect::MakeSize(x_server_pixel_buffer_.window_size()));
-
-    for (DesktopRegion::Iterator it(*updated_region);
-         !it.IsAtEnd(); it.Advance()) {
-      if (!x_server_pixel_buffer_.CaptureRect(it.rect(), frame.get()))
-        return nullptr;
-    }
-  } else {
+  {
     // Doing full-screen polling, or this is the first capture after a
     // screen-resolution change.  In either case, need a full-screen capture.
     DesktopRect screen_rect = DesktopRect::MakeSize(frame->size());
     if (!x_server_pixel_buffer_.CaptureRect(screen_rect, frame.get()))
       return nullptr;
     updated_region->SetRect(screen_rect);
   }
 
@@ -297,21 +223,16 @@ void ScreenCapturerX11::DeinitXlib() {
   if (gc_) {
     XFreeGC(display(), gc_);
     gc_ = nullptr;
   }
 
   x_server_pixel_buffer_.Release();
 
   if (display()) {
-    if (damage_handle_) {
-      XDamageDestroy(display(), damage_handle_);
-      damage_handle_ = 0;
-    }
-
     if (damage_region_) {
       XFixesDestroyRegion(display(), damage_region_);
       damage_region_ = 0;
     }
   }
 }
 
 // static
diff --git a/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/window_capturer_x11.cc b/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/window_capturer_x11.cc
--- a/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/window_capturer_x11.cc
+++ b/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/window_capturer_x11.cc
@@ -5,17 +5,16 @@
  *  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/linux/window_capturer_x11.h"
 
-#include <X11/extensions/Xcomposite.h>
 #include <X11/extensions/Xrender.h>
 #include <X11/Xutil.h>
 
 #include <memory>
 #include <string>
 #include <utility>
 
 #include "modules/desktop_capture/desktop_frame.h"
@@ -28,25 +27,17 @@
 #include "modules/desktop_capture/linux/shared_x_util.h"
 
 namespace webrtc {
 
 WindowCapturerX11::WindowCapturerX11(const DesktopCaptureOptions& options)
     : x_display_(options.x_display()),
       atom_cache_(display()),
       window_finder_(&atom_cache_) {
-  int event_base, error_base, major_version, minor_version;
-  if (XCompositeQueryExtension(display(), &event_base, &error_base) &&
-      XCompositeQueryVersion(display(), &major_version, &minor_version) &&
-      // XCompositeNameWindowPixmap() requires version 0.2
-      (major_version > 0 || minor_version >= 2)) {
-    has_composite_extension_ = true;
-  } else {
-    RTC_LOG(LS_INFO) << "Xcomposite extension not available or too old.";
-  }
+  RTC_LOG(LS_INFO) << "Xcomposite extension not available or too old.";
 
   x_display_->AddEventHandler(ConfigureNotify, this);
 }
 
 WindowCapturerX11::~WindowCapturerX11() {
   x_display_->RemoveEventHandler(ConfigureNotify, this);
 }
 
@@ -74,17 +65,17 @@ bool WindowCapturerX11::SelectSource(Sou
 
   // In addition to needing X11 server-side support for Xcomposite, it actually
   // needs to be turned on for the window. If the user has modern
   // hardware/drivers but isn't using a compositing window manager, that won't
   // be the case. Here we automatically turn it on.
 
   // Redirect drawing to an offscreen buffer (ie, turn on compositing). X11
   // remembers who has requested this and will turn it off for us when we exit.
-  XCompositeRedirectWindow(display(), id, CompositeRedirectAutomatic);
+  // XCompositeRedirectWindow(display(), id, CompositeRedirectAutomatic);
 
   return true;
 }
 
 bool WindowCapturerX11::FocusOnSelectedSource() {
   if (!selected_window_)
     return false;
 
diff --git a/media/webrtc/trunk/webrtc/webrtc_gn/moz.build b/media/webrtc/trunk/webrtc/webrtc_gn/moz.build
--- a/media/webrtc/trunk/webrtc/webrtc_gn/moz.build
+++ b/media/webrtc/trunk/webrtc/webrtc_gn/moz.build
@@ -135,19 +135,17 @@ if CONFIG["OS_TARGET"] == "Linux":
     DEFINES["_FILE_OFFSET_BITS"] = "64"
 
     OS_LIBS += [
         "m",
         "rt",
         "X11",
         "X11-xcb",
         "xcb",
-        "Xcomposite",
         "Xcursor",
-        "Xdamage",
         "Xext",
         "Xfixes",
         "Xi",
         "Xrender"
     ]
 
 if CONFIG["OS_TARGET"] == "NetBSD":
 
diff --git a/old-configure.in b/old-configure.in
--- a/old-configure.in
+++ b/old-configure.in
@@ -1762,17 +1762,17 @@ fi
 AC_TRY_COMPILE([#include <linux/ethtool.h>],
                [ struct ethtool_cmd cmd; cmd.speed_hi = 0; ],
                MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI=1)
 
 AC_SUBST(MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI)
 
 if test -n "$MOZ_WEBRTC"; then
     if test -n "$MOZ_X11"; then
-      MOZ_WEBRTC_X11_LIBS="-lXext -lXdamage -lXfixes -lXcomposite"
+      MOZ_WEBRTC_X11_LIBS="-lXext -lXfixes"
     fi
 fi
 
 AC_SUBST_LIST(MOZ_WEBRTC_X11_LIBS)
 
 dnl ========================================================
 dnl = Apple platform decoder support
 dnl ========================================================
diff --git a/security/sandbox/linux/SandboxFilter.cpp b/security/sandbox/linux/SandboxFilter.cpp
--- a/security/sandbox/linux/SandboxFilter.cpp
+++ b/security/sandbox/linux/SandboxFilter.cpp
@@ -915,17 +915,19 @@ class ContentSandboxPolicy : public Sand
 
   ~ContentSandboxPolicy() override = default;
 
   Maybe<ResultExpr> EvaluateSocketCall(int aCall,
                                        bool aHasArgs) const override {
     switch (aCall) {
       case SYS_RECVFROM:
       case SYS_SENDTO:
+#if defined(SYS_SENDMMSG)
       case SYS_SENDMMSG:  // libresolv via libasyncns; see bug 1355274
+#endif
         return Some(Allow());
 
 #ifdef ANDROID
       case SYS_SOCKET:
         return Some(Error(EACCES));
 #else  // #ifdef DESKTOP
       case SYS_SOCKET: {
         const auto trapFn = aHasArgs ? FakeSocketTrap : FakeSocketTrapLegacy;
@@ -1571,17 +1573,19 @@ class SocketProcessSandboxPolicy final :
       case SYS_SOCKET:
         return Some(Allow());
 
       case SYS_CONNECT:
         return Some(Allow());
 
       case SYS_RECVFROM:
       case SYS_SENDTO:
+#if defined(SYS_SENDMMSG)
       case SYS_SENDMMSG:
+#endif
         return Some(Allow());
 
       case SYS_RECV:
       case SYS_SEND:
       case SYS_GETSOCKOPT:
       case SYS_SETSOCKOPT:
       case SYS_GETSOCKNAME:
       case SYS_GETPEERNAME:
diff --git a/security/sandbox/linux/SandboxReporterClient.cpp b/security/sandbox/linux/SandboxReporterClient.cpp
--- a/security/sandbox/linux/SandboxReporterClient.cpp
+++ b/security/sandbox/linux/SandboxReporterClient.cpp
@@ -44,17 +44,17 @@ SandboxReporterClient::SandboxReporterCl
 SandboxReport SandboxReporterClient::MakeReport(const void* aContext) {
   SandboxReport report;
   const auto ctx = static_cast<const ucontext_t*>(aContext);
 
   // Zero the entire struct; some memory safety analyses care about
   // sending uninitialized alignment padding to another process.
   PodZero(&report);
 
-  clock_gettime(CLOCK_MONOTONIC_COARSE, &report.mTime);
+  clock_gettime(CLOCK_MONOTONIC, &report.mTime);
   report.mPid = getpid();
   report.mTid = syscall(__NR_gettid);
   report.mProcType = mProcType;
   report.mSyscall = SECCOMP_SYSCALL(ctx);
   report.mArgs[0] = SECCOMP_PARM1(ctx);
   report.mArgs[1] = SECCOMP_PARM2(ctx);
   report.mArgs[2] = SECCOMP_PARM3(ctx);
   report.mArgs[3] = SECCOMP_PARM4(ctx);
diff --git a/security/sandbox/linux/reporter/SandboxReporterWrappers.cpp b/security/sandbox/linux/reporter/SandboxReporterWrappers.cpp
--- a/security/sandbox/linux/reporter/SandboxReporterWrappers.cpp
+++ b/security/sandbox/linux/reporter/SandboxReporterWrappers.cpp
@@ -33,17 +33,17 @@ class SandboxReportWrapper final : publi
   SandboxReport mReport;
 };
 
 NS_IMPL_ISUPPORTS(SandboxReportWrapper, mozISandboxReport)
 
 /* readonly attribute uint64_t msecAgo; */
 NS_IMETHODIMP SandboxReportWrapper::GetMsecAgo(uint64_t* aMsec) {
   struct timespec then = mReport.mTime, now = {0, 0};
-  clock_gettime(CLOCK_MONOTONIC_COARSE, &now);
+  clock_gettime(CLOCK_MONOTONIC, &now);
 
   const uint64_t now_msec = uint64_t(now.tv_sec) * 1000 + now.tv_nsec / 1000000;
   const uint64_t then_msec =
       uint64_t(then.tv_sec) * 1000 + then.tv_nsec / 1000000;
   MOZ_DIAGNOSTIC_ASSERT(now_msec >= then_msec);
   if (now_msec >= then_msec) {
     *aMsec = now_msec - then_msec;
   } else {
diff --git a/widget/nsShmImage.h b/widget/nsShmImage.h
--- a/widget/nsShmImage.h
+++ b/widget/nsShmImage.h
@@ -12,18 +12,20 @@
 #endif
 
 #ifdef MOZ_HAVE_SHMIMAGE
 
 #  include "mozilla/gfx/2D.h"
 #  include "nsIWidget.h"
 #  include "Units.h"
 
+extern "C" {
 #  include <X11/Xlib-xcb.h>
 #  include <xcb/shm.h>
+}
 
 class nsShmImage {
   // bug 1168843, compositor thread may create shared memory instances that are
   // destroyed by main thread on shutdown, so this must use thread-safe RC to
   // avoid hitting assertion
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(nsShmImage)
 
  public:
