• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 MODULES_DESKTOP_CAPTURE_WIN_DESKTOP_H_
12 #define MODULES_DESKTOP_CAPTURE_WIN_DESKTOP_H_
13 
14 #include <windows.h>
15 
16 #include <string>
17 
18 #include "rtc_base/constructor_magic.h"
19 #include "rtc_base/system/rtc_export.h"
20 
21 namespace webrtc {
22 
23 class RTC_EXPORT Desktop {
24  public:
25   ~Desktop();
26 
27   // Returns the name of the desktop represented by the object. Return false if
28   // quering the name failed for any reason.
29   bool GetName(std::wstring* desktop_name_out) const;
30 
31   // Returns true if |other| has the same name as this desktop. Returns false
32   // in any other case including failing Win32 APIs and uninitialized desktop
33   // handles.
34   bool IsSame(const Desktop& other) const;
35 
36   // Assigns the desktop to the current thread. Returns false is the operation
37   // failed for any reason.
38   bool SetThreadDesktop() const;
39 
40   // Returns the desktop by its name or NULL if an error occurs.
41   static Desktop* GetDesktop(const wchar_t* desktop_name);
42 
43   // Returns the desktop currently receiving user input or NULL if an error
44   // occurs.
45   static Desktop* GetInputDesktop();
46 
47   // Returns the desktop currently assigned to the calling thread or NULL if
48   // an error occurs.
49   static Desktop* GetThreadDesktop();
50 
51  private:
52   Desktop(HDESK desktop, bool own);
53 
54   // The desktop handle.
55   HDESK desktop_;
56 
57   // True if |desktop_| must be closed on teardown.
58   bool own_;
59 
60   RTC_DISALLOW_COPY_AND_ASSIGN(Desktop);
61 };
62 
63 }  // namespace webrtc
64 
65 #endif  // MODULES_DESKTOP_CAPTURE_WIN_DESKTOP_H_
66