FreeRDP
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
sdl_common_utils.cpp
1
21#include "sdl_common_utils.hpp"
22
24{
25 InitializeCriticalSection(&_section);
26}
27
28CriticalSection::~CriticalSection()
29{
30 DeleteCriticalSection(&_section);
31}
32
33void CriticalSection::lock()
34{
35 EnterCriticalSection(&_section);
36}
37
38void CriticalSection::unlock()
39{
40 LeaveCriticalSection(&_section);
41}
42
43WinPREvent::WinPREvent(bool initial) : _handle(CreateEventA(nullptr, TRUE, initial, nullptr))
44{
45}
46
47WinPREvent::~WinPREvent()
48{
49 (void)CloseHandle(_handle);
50}
51
52void WinPREvent::set()
53{
54 (void)SetEvent(_handle);
55}
56
57void WinPREvent::clear()
58{
59 (void)ResetEvent(_handle);
60}
61
62bool WinPREvent::isSet() const
63{
64 return WaitForSingleObject(_handle, 0) == WAIT_OBJECT_0;
65}
66
67HANDLE WinPREvent::handle() const
68{
69 return _handle;
70}
71
72bool operator==(const rdpMonitor& l, const rdpMonitor& r)
73{
74 if (l.x != r.x)
75 return false;
76 if (l.y != r.y)
77 return false;
78 if (l.width != r.width)
79 return false;
80 if (l.height != r.height)
81 return false;
82 if (l.is_primary != r.is_primary)
83 return false;
84 if (l.orig_screen != r.orig_screen)
85 return false;
86
87 return l.attributes == r.attributes;
88}
89
90bool operator==(const MONITOR_ATTRIBUTES& l, const MONITOR_ATTRIBUTES& r)
91{
92 if (l.physicalWidth != r.physicalWidth)
93 return false;
94 if (l.physicalHeight != r.physicalHeight)
95 return false;
96 if (l.orientation != r.orientation)
97 return false;
98 if (l.desktopScaleFactor != r.desktopScaleFactor)
99 return false;
100 if (l.deviceScaleFactor != r.deviceScaleFactor)
101 return false;
102 return true;
103}