diff --git a/webrtc/modules/desktop_capture/window_capturer_x11.cc b/webrtc/modules/desktop_capture/window_capturer_x11.cc index ffe8a3ab9b..62c258ae85 100644 --- a/webrtc/modules/desktop_capture/window_capturer_x11.cc +++ b/webrtc/modules/desktop_capture/window_capturer_x11.cc @@ -111,6 +111,9 @@ class WindowCapturerLinux : public DesktopCapturer, // Returns window title for the specified X |window|. bool GetWindowTitle(::Window window, std::string* title); + // Return WM_STATE property of the |window|. + int32_t GetWindowState(::Window window); + Callback* callback_ = nullptr; rtc::scoped_refptr x_display_; @@ -286,6 +289,14 @@ void WindowCapturerLinux::CaptureFrame() { return; } + if (GetWindowState(selected_window_) == IconicState) { + // Window is in minimized. Return a 1x1 frame as same as OSX/Win does. + std::unique_ptr frame( + new BasicDesktopFrame(DesktopSize(1, 1))); + callback_->OnCaptureResult(Result::SUCCESS, std::move(frame)); + return; + } + std::unique_ptr frame( new BasicDesktopFrame(x_server_pixel_buffer_.window_size())); @@ -317,13 +328,7 @@ bool WindowCapturerLinux::HandleXEvent(const XEvent& event) { } ::Window WindowCapturerLinux::GetApplicationWindow(::Window window) { - // Get WM_STATE property of the window. - XWindowProperty window_state(display(), window, wm_state_atom_); - - // WM_STATE is considered to be set to WithdrawnState when it missing. - int32_t state = window_state.is_valid() ? - *window_state.data() : WithdrawnState; - + int32_t state = GetWindowState(window); if (state == NormalState) { // Window has WM_STATE==NormalState. Return it. return window; @@ -418,6 +423,14 @@ bool WindowCapturerLinux::GetWindowTitle(::Window window, std::string* title) { return result; } +int32_t WindowCapturerLinux::GetWindowState(::Window window) { + // Get WM_STATE property of the window. + XWindowProperty window_state(display(), window, wm_state_atom_); + + // WM_STATE is considered to be set to WithdrawnState when it missing. + return window_state.is_valid() ? *window_state.data() : WithdrawnState; +} + } // namespace // static