From fb1eb43377404ef29c41adff69e0f2ba77df8d63 Mon Sep 17 00:00:00 2001 From: "henrike@webrtc.org" Date: Fri, 15 Aug 2014 14:44:13 +0000 Subject: [PATCH] Rename linuxwindowpicker to x11windowpicker & only use it with use_x11 These days we have Linux chromium builds that don't use X11. We don't want webrtc to add an X11 dependency to those builds. BUG=3625 R=henrike@webrtc.org, tnakamura@webrtc.org Review URL: https://webrtc-codereview.appspot.com/20049004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@6909 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/base/BUILD.gn | 10 +++++-- webrtc/base/base.gyp | 26 +++++++++++----- webrtc/base/windowpickerfactory.h | 7 +++-- ...inuxwindowpicker.cc => x11windowpicker.cc} | 30 +++++++++---------- ...{linuxwindowpicker.h => x11windowpicker.h} | 6 ++-- ...nittest.cc => x11windowpicker_unittest.cc} | 10 +++---- 6 files changed, 54 insertions(+), 35 deletions(-) rename webrtc/base/{linuxwindowpicker.cc => x11windowpicker.cc} (96%) rename webrtc/base/{linuxwindowpicker.h => x11windowpicker.h} (94%) rename webrtc/base/{linuxwindowpicker_unittest.cc => x11windowpicker_unittest.cc} (82%) diff --git a/webrtc/base/BUILD.gn b/webrtc/base/BUILD.gn index 7a15add303..32bc55601e 100644 --- a/webrtc/base/BUILD.gn +++ b/webrtc/base/BUILD.gn @@ -9,6 +9,7 @@ # TODO(kjellander): Rebase this to base.gyp changes after r6438. import("//build/config/crypto.gni") +import("//build/config/ui.gni") import("../build/webrtc.gni") config("webrtc_base_config") { @@ -401,8 +402,13 @@ static_library("webrtc_base") { "libdbusglibsymboltable.h", "linuxfdwalk.c", "linuxfdwalk.h", - "linuxwindowpicker.cc", - "linuxwindowpicker.h", + ] + } + + if (use_x11) { + sources += [ + "x11windowpicker.cc", + "x11windowpicker.h", ] } diff --git a/webrtc/base/base.gyp b/webrtc/base/base.gyp index ba5678e735..0e5845e755 100644 --- a/webrtc/base/base.gyp +++ b/webrtc/base/base.gyp @@ -127,8 +127,6 @@ 'linux.h', 'linuxfdwalk.c', 'linuxfdwalk.h', - 'linuxwindowpicker.cc', - 'linuxwindowpicker.h', 'linked_ptr.h', 'logging.cc', 'logging.h', @@ -311,6 +309,8 @@ 'winping.h', 'worker.cc', 'worker.h', + 'x11windowpicker.cc', + 'x11windowpicker.h', '../overrides/webrtc/base/basictypes.h', '../overrides/webrtc/base/constructormagic.h', '../overrides/webrtc/base/logging.cc', @@ -381,8 +381,8 @@ 'libdbusglibsymboltable.h', 'linuxfdwalk.c', 'linuxfdwalk.h', - 'linuxwindowpicker.cc', - 'linuxwindowpicker.h', + 'x11windowpicker.cc', + 'x11windowpicker.h', 'logging.cc', 'logging.h', 'macasyncsocket.cc', @@ -569,7 +569,7 @@ }], ], }], - ['OS=="linux"', { + ['use_x11 == 1', { 'link_settings': { 'libraries': [ '-ldl', @@ -580,6 +580,20 @@ '-lXrender', ], }, + }, { + 'sources!': [ + 'x11windowpicker.cc', + 'x11windowpicker.h', + ], + }], + ['OS=="linux"', { + 'link_settings': { + 'libraries': [ + '-lcrypto', + '-ldl', + '-lrt', + ], + }, 'conditions': [ ['build_ssl==1', { 'link_settings': { @@ -602,8 +616,6 @@ 'libdbusglibsymboltable.cc', 'libdbusglibsymboltable.h', 'linuxfdwalk.c', - 'linuxwindowpicker.cc', - 'linuxwindowpicker.h', ], }], ['OS=="mac"', { diff --git a/webrtc/base/windowpickerfactory.h b/webrtc/base/windowpickerfactory.h index 00a4cc469e..7de107ebca 100644 --- a/webrtc/base/windowpickerfactory.h +++ b/webrtc/base/windowpickerfactory.h @@ -16,8 +16,8 @@ #elif defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) #include "webrtc/base/macutils.h" #include "webrtc/base/macwindowpicker.h" -#elif defined(WEBRTC_LINUX) && !defined(WEBRTC_ANDROID) -#include "webrtc/base/linuxwindowpicker.h" +#elif defined(WEBRTC_LINUX) && !defined(WEBRTC_ANDROID) && defined(HAVE_X11) +#include "webrtc/base/x11windowpicker.h" #endif #include "webrtc/base/windowpicker.h" @@ -39,7 +39,8 @@ class WindowPickerFactory { #elif defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) return new MacWindowPicker(); #elif defined(WEBRTC_LINUX) && !defined(WEBRTC_ANDROID) && defined(HAVE_X11) - return new LinuxWindowPicker(); + return new X11WindowPicker(); +#error #else return NULL; #endif diff --git a/webrtc/base/linuxwindowpicker.cc b/webrtc/base/x11windowpicker.cc similarity index 96% rename from webrtc/base/linuxwindowpicker.cc rename to webrtc/base/x11windowpicker.cc index 56d565e554..7e47f6a181 100644 --- a/webrtc/base/linuxwindowpicker.cc +++ b/webrtc/base/x11windowpicker.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/base/linuxwindowpicker.h" +#include "webrtc/base/x11windowpicker.h" #include #include @@ -625,7 +625,7 @@ class XWindowEnumerator { Window app_window = GetApplicationWindow(children[num_children - 1 - i]); #endif if (app_window && - !LinuxWindowPicker::IsDesktopElement(display_, app_window)) { + !X11WindowPicker::IsDesktopElement(display_, app_window)) { std::string title; if (GetWindowTitle(app_window, &title)) { WindowId id(app_window); @@ -721,13 +721,13 @@ class XWindowEnumerator { bool has_render_extension_; }; -LinuxWindowPicker::LinuxWindowPicker() : enumerator_(new XWindowEnumerator()) { +X11WindowPicker::X11WindowPicker() : enumerator_(new XWindowEnumerator()) { } -LinuxWindowPicker::~LinuxWindowPicker() { +X11WindowPicker::~X11WindowPicker() { } -bool LinuxWindowPicker::IsDesktopElement(_XDisplay* display, Window window) { +bool X11WindowPicker::IsDesktopElement(_XDisplay* display, Window window) { if (window == 0) { LOG(LS_WARNING) << "Zero is never a valid window."; return false; @@ -769,48 +769,48 @@ bool LinuxWindowPicker::IsDesktopElement(_XDisplay* display, Window window) { return result; } -bool LinuxWindowPicker::Init() { +bool X11WindowPicker::Init() { return enumerator_->Init(); } -bool LinuxWindowPicker::GetWindowList(WindowDescriptionList* descriptions) { +bool X11WindowPicker::GetWindowList(WindowDescriptionList* descriptions) { return enumerator_->EnumerateWindows(descriptions); } -bool LinuxWindowPicker::GetDesktopList(DesktopDescriptionList* descriptions) { +bool X11WindowPicker::GetDesktopList(DesktopDescriptionList* descriptions) { return enumerator_->EnumerateDesktops(descriptions); } -bool LinuxWindowPicker::IsVisible(const WindowId& id) { +bool X11WindowPicker::IsVisible(const WindowId& id) { return enumerator_->IsVisible(id); } -bool LinuxWindowPicker::MoveToFront(const WindowId& id) { +bool X11WindowPicker::MoveToFront(const WindowId& id) { return enumerator_->MoveToFront(id); } -uint8* LinuxWindowPicker::GetWindowIcon(const WindowId& id, int* width, +uint8* X11WindowPicker::GetWindowIcon(const WindowId& id, int* width, int* height) { return enumerator_->GetWindowIcon(id, width, height); } -uint8* LinuxWindowPicker::GetWindowThumbnail(const WindowId& id, int width, +uint8* X11WindowPicker::GetWindowThumbnail(const WindowId& id, int width, int height) { return enumerator_->GetWindowThumbnail(id, width, height); } -int LinuxWindowPicker::GetNumDesktops() { +int X11WindowPicker::GetNumDesktops() { return enumerator_->GetNumDesktops(); } -uint8* LinuxWindowPicker::GetDesktopThumbnail(const DesktopId& id, +uint8* X11WindowPicker::GetDesktopThumbnail(const DesktopId& id, int width, int height) { return enumerator_->GetDesktopThumbnail(id, width, height); } -bool LinuxWindowPicker::GetDesktopDimensions(const DesktopId& id, int* width, +bool X11WindowPicker::GetDesktopDimensions(const DesktopId& id, int* width, int* height) { return enumerator_->GetDesktopDimensions(id, width, height); } diff --git a/webrtc/base/linuxwindowpicker.h b/webrtc/base/x11windowpicker.h similarity index 94% rename from webrtc/base/linuxwindowpicker.h rename to webrtc/base/x11windowpicker.h index f87b15081c..26c70549b2 100644 --- a/webrtc/base/linuxwindowpicker.h +++ b/webrtc/base/x11windowpicker.h @@ -23,10 +23,10 @@ namespace rtc { class XWindowEnumerator; -class LinuxWindowPicker : public WindowPicker { +class X11WindowPicker : public WindowPicker { public: - LinuxWindowPicker(); - ~LinuxWindowPicker(); + X11WindowPicker(); + ~X11WindowPicker(); static bool IsDesktopElement(_XDisplay* display, Window window); diff --git a/webrtc/base/linuxwindowpicker_unittest.cc b/webrtc/base/x11windowpicker_unittest.cc similarity index 82% rename from webrtc/base/linuxwindowpicker_unittest.cc rename to webrtc/base/x11windowpicker_unittest.cc index c2276ccd63..482ac89aad 100644 --- a/webrtc/base/linuxwindowpicker_unittest.cc +++ b/webrtc/base/x11windowpicker_unittest.cc @@ -9,7 +9,7 @@ */ #include "webrtc/base/gunit.h" -#include "webrtc/base/linuxwindowpicker.h" +#include "webrtc/base/x11windowpicker.h" #include "webrtc/base/logging.h" #include "webrtc/base/testutils.h" #include "webrtc/base/windowpicker.h" @@ -20,17 +20,17 @@ namespace rtc { -TEST(LinuxWindowPickerTest, TestGetWindowList) { +TEST(X11WindowPickerTest, TestGetWindowList) { MAYBE_SKIP_SCREENCAST_TEST(); - LinuxWindowPicker window_picker; + X11WindowPicker window_picker; WindowDescriptionList descriptions; window_picker.Init(); window_picker.GetWindowList(&descriptions); } -TEST(LinuxWindowPickerTest, TestGetDesktopList) { +TEST(X11WindowPickerTest, TestGetDesktopList) { MAYBE_SKIP_SCREENCAST_TEST(); - LinuxWindowPicker window_picker; + X11WindowPicker window_picker; DesktopDescriptionList descriptions; EXPECT_TRUE(window_picker.Init()); EXPECT_TRUE(window_picker.GetDesktopList(&descriptions));