blob: fda56ca8d812f5f9e2d671757cd67f700212ccc8 [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
henrike@webrtc.org88fbb2d2014-05-21 21:18:46 +000017#include "webrtc/base/constructormagic.h"
sergeyu@chromium.org3d34f662013-06-04 18:51:23 +000018#include "webrtc/system_wrappers/interface/scoped_ptr.h"
19
20namespace webrtc {
21
22class Desktop {
23 public:
24 ~Desktop();
25
26 // Returns the name of the desktop represented by the object. Return false if
27 // quering the name failed for any reason.
28 bool GetName(std::wstring* desktop_name_out) const;
29
30 // Returns true if |other| has the same name as this desktop. Returns false
31 // in any other case including failing Win32 APIs and uninitialized desktop
32 // handles.
33 bool IsSame(const Desktop& other) const;
34
35 // Assigns the desktop to the current thread. Returns false is the operation
36 // failed for any reason.
37 bool SetThreadDesktop() const;
38
39 // Returns the desktop by its name or NULL if an error occurs.
40 static Desktop* GetDesktop(const wchar_t* desktop_name);
41
42 // Returns the desktop currently receiving user input or NULL if an error
43 // occurs.
44 static Desktop* GetInputDesktop();
45
46 // Returns the desktop currently assigned to the calling thread or NULL if
47 // an error occurs.
48 static Desktop* GetThreadDesktop();
49
50 private:
51 Desktop(HDESK desktop, bool own);
52
53 // The desktop handle.
54 HDESK desktop_;
55
56 // True if |desktop_| must be closed on teardown.
57 bool own_;
58
59 DISALLOW_COPY_AND_ASSIGN(Desktop);
60};
61
62} // namespace webrtc
63
64#endif // WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_DESKTOP_H_