summaryrefslogtreecommitdiffstats
path: root/remoting/host/win/window_station_and_desktop.h
blob: 21c28b0089363813f48d904fee190b522ff5f3e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef REMOTING_HOST_WIN_WINDOW_STATION_AND_DESKTOP_H_
#define REMOTING_HOST_WIN_WINDOW_STATION_AND_DESKTOP_H_

#include <windows.h>

#include "base/macros.h"

namespace remoting {

// Scoper for a pair of window station and desktop handles. Both handles are
// closed when the object goes out of scope.
class WindowStationAndDesktop {
 public:
  WindowStationAndDesktop();
  ~WindowStationAndDesktop();

  HDESK desktop() const { return desktop_; }
  HWINSTA window_station() const { return window_station_; }

  // Sets a new desktop handle closing the owned desktop handle if needed.
  void SetDesktop(HDESK desktop);

  // Sets a new window station handle closing the owned window station handle
  // if needed.
  void SetWindowStation(HWINSTA window_station);

  // Swaps contents with the other WindowStationAndDesktop.
  void Swap(WindowStationAndDesktop& other);

 private:
  HDESK desktop_;
  HWINSTA window_station_;

  DISALLOW_COPY_AND_ASSIGN(WindowStationAndDesktop);
};

}  // namespace remoting

#endif  // REMOTING_HOST_WIN_WINDOW_STATION_AND_DESKTOP_H_