windowCapture: return 1x1 frame to minimized winodw on Linux.
During window capturing, if the target window is minimized, OSX/Windows will return a 1x1 frame and then webrtc knows to replace it with a black frame. Let's do same on Linux too. BUG=568840 Review-Url: https://codereview.webrtc.org/2989233002 Cr-Commit-Position: refs/heads/master@{#19224}
This commit is contained in:
parent
dd7d8f1b60
commit
adb161fecc
@ -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<SharedXDisplay> 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<DesktopFrame> frame(
|
||||
new BasicDesktopFrame(DesktopSize(1, 1)));
|
||||
callback_->OnCaptureResult(Result::SUCCESS, std::move(frame));
|
||||
return;
|
||||
}
|
||||
|
||||
std::unique_ptr<DesktopFrame> 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<uint32_t> 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<uint32_t> 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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user