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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
/*
Copyright (C) 2009 Red Hat, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _H_DESKTOP_LAYOUT
#define _H_DESKTOP_LAYOUT
#include "mutex.h"
#include <vector>
class DisplayMode {
public:
DisplayMode(LONG pos_x, LONG pos_y, DWORD width, DWORD height, DWORD depth, bool attached)
: _pos_x (pos_x)
, _pos_y (pos_y)
, _width (width)
, _height (height)
, _depth (depth)
, _attached (attached)
{
}
LONG get_pos_x() { return _pos_x;}
LONG get_pos_y() { return _pos_y;}
DWORD get_width() { return _width;}
DWORD get_height() { return _height;}
DWORD get_depth() { return _depth;}
bool get_attached() { return _attached;}
void set_pos(LONG x, LONG y) { _pos_x = x; _pos_y = y;}
void move_pos(LONG x, LONG y) { _pos_x += x; _pos_y += y;}
void set_res(DWORD width, DWORD height, DWORD depth);
void set_attached(bool attached) { _attached = attached;}
private:
LONG _pos_x;
LONG _pos_y;
DWORD _width;
DWORD _height;
DWORD _depth;
bool _attached;
};
typedef std::vector<DisplayMode*> Displays;
class DesktopLayout {
public:
DesktopLayout();
~DesktopLayout();
void get_displays();
void set_displays();
void lock() { MUTEX_LOCK(_mutex);}
void unlock() { MUTEX_UNLOCK(_mutex);}
DisplayMode* get_display(int i) { return _displays.at(i);}
size_t get_display_count() { return _displays.size();}
DWORD get_total_width() { return _total_width;}
DWORD get_total_height() { return _total_height;}
private:
void clean_displays();
static bool is_attached(LPCTSTR dev_name);
static bool get_qxl_device_id(WCHAR* device_key, DWORD* device_id);
static void init_dev_mode(DEVMODE* dev_mode, DisplayMode* mode, bool set_pos);
private:
mutex_t _mutex;
Displays _displays;
DWORD _total_width;
DWORD _total_height;
};
#endif
|