blob: 673731679fa17e9e93e33a4109bbc5d00731665a [file] [log] [blame]
sergeyu@chromium.org3d34f662013-06-04 18:51:23 +00001/*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_DESKTOP_H_
12#define WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_DESKTOP_H_
13
mcasas@webrtc.org2fa7f792014-05-21 11:07:29 +000014#include <windows.h>
henrike@webrtc.org88fbb2d2014-05-21 21:18:46 +000015#include <string>
sergeyu@chromium.org3d34f662013-06-04 18:51:23 +000016
Edward Lemurc20978e2017-07-06 19:44:34 +020017#include "webrtc/rtc_base/constructormagic.h"
sergeyu@chromium.org3d34f662013-06-04 18:51:23 +000018
19namespace webrtc {
20
21class Desktop {
22 public:
23 ~Desktop();
24
25 // Returns the name of the desktop represented by the object. Return false if
26 // quering the name failed for any reason.
27 bool GetName(std::wstring* desktop_name_out) const;
28
29 // Returns true if |other| has the same name as this desktop. Returns false
30 // in any other case including failing Win32 APIs and uninitialized desktop
31 // handles.
32 bool IsSame(const Desktop& other) const;
33
34 // Assigns the desktop to the current thread. Returns false is the operation
35 // failed for any reason.
36 bool SetThreadDesktop() const;
37
38 // Returns the desktop by its name or NULL if an error occurs.
39 static Desktop* GetDesktop(const wchar_t* desktop_name);
40
41 // Returns the desktop currently receiving user input or NULL if an error
42 // occurs.
43 static Desktop* GetInputDesktop();
44
45 // Returns the desktop currently assigned to the calling thread or NULL if
46 // an error occurs.
47 static Desktop* GetThreadDesktop();
48
49 private:
50 Desktop(HDESK desktop, bool own);
51
52 // The desktop handle.
53 HDESK desktop_;
54
55 // True if |desktop_| must be closed on teardown.
56 bool own_;
57
henrikg3c089d72015-09-16 05:37:44 -070058 RTC_DISALLOW_COPY_AND_ASSIGN(Desktop);
sergeyu@chromium.org3d34f662013-06-04 18:51:23 +000059};
60
61} // namespace webrtc
62
63#endif // WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_DESKTOP_H_