Skip to content

Commit 5d4caeb

Browse files
authored
Cleaned up code base (#1171)
1 parent 8cf5dd0 commit 5d4caeb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+552
-593
lines changed

Files.Extensions/SysProc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ int SysProc::GetSlateState()
2121
int SysProc::GetTabletPCState()
2222
{
2323
return pGetSystemMetrics(SM_TABLETPC);
24-
}
24+
}

Files.Extensions/SysProc.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@ class SysProc
1212
static int GetSlateState();
1313
static int GetTabletPCState();
1414
};
15-

Files.Extensions/TEBProc.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ Readapted from: https://raw.githubusercontent.com/gus33000/RegistryRT/master/pch
2929
#include <winrt/base.h>
3030
#include <algorithm>
3131

32-
3332
using namespace winrt;
3433

3534
typedef struct _UNICODE_STRING {

Files.Extensions/UserInteractionMode.cpp

Lines changed: 114 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -8,117 +8,117 @@ using namespace winrt::Windows;
88

99
namespace winrt::Files_Extensions::implementation
1010
{
11-
Windows::UI::Xaml::DispatcherTimer m_timer;
12-
int currentSlateState = 0;
13-
14-
NTSTATUS NTAPI WnfCallback(const ULONG64 state_name, void* p2, void* p3, void* callbackContext, void* buffer, ULONG bufferSize)
15-
{
16-
if (((UserInteractionMode*)callbackContext)->IsSubscribed())
17-
((UserInteractionMode*)callbackContext)->InvokeTabletModeChange();
18-
19-
return 0;
20-
}
21-
22-
void UserInteractionMode::InvokeTabletModeChange()
23-
{
24-
const auto inter = GetUserInteractionMode();
25-
event_userInteractionModeChanged(*this, inter);
26-
}
27-
28-
event_token UserInteractionMode::UserInteractionModeChanged(Windows::Foundation::EventHandler<UserInteractionType> const& handler)
29-
{
30-
if (numSub_userInteractionModeChangedEvent++ == 0)
31-
{
32-
isSubscribed = true;
33-
currentSlateState = GetSlateState();
34-
35-
Windows::Foundation::TimeSpan dur(2500000L);
36-
m_timer.Interval(dur);
37-
m_timer.Tick([this](Windows::Foundation::IInspectable const&, Windows::Foundation::IInspectable const&)
38-
{
39-
const auto curSlat = GetSlateState();
40-
if (curSlat != currentSlateState)
41-
{
42-
currentSlateState = curSlat;
43-
InvokeTabletModeChange();
44-
}
45-
else
46-
currentSlateState = curSlat;
47-
});
48-
m_timer.Start();
49-
50-
if (firstTimeSubscription)
51-
{
52-
Wnf::SubscribeWnf(WNF_TMCN_ISTABLETMODE, WnfCallback, (intptr_t)this);
53-
firstTimeSubscription = false;
54-
}
55-
}
56-
57-
return event_userInteractionModeChanged.add(handler);
58-
}
59-
60-
void UserInteractionMode::UserInteractionModeChanged(winrt::event_token const& token) noexcept
61-
{
62-
if (--numSub_userInteractionModeChangedEvent == 0)
63-
{
64-
//Wnf::UnsubscribeWnf(WnfCallback);
65-
isSubscribed = false;
66-
m_timer.Stop();
67-
}
68-
69-
event_userInteractionModeChanged.remove(token);
70-
}
71-
72-
UserInteractionType UserInteractionMode::GetUserInteractionMode()
73-
{
74-
bool res = Wnf::IsTabletMode();
75-
bool slate = GetSlateState();
76-
77-
if (res)
78-
{
79-
if (slate)
80-
return UserInteractionType::TouchInTabletMode;
81-
else
82-
return UserInteractionType::MouseInTabletMode;
83-
}
84-
else
85-
{
86-
if (slate)
87-
return UserInteractionType::TouchInDesktopMode;
88-
else
89-
return UserInteractionType::MouseInDesktopMode;
90-
}
91-
}
92-
93-
//0 = normal mode, 1 = slate mode, -1 = not a slate
94-
int UserInteractionMode::GetSlateStateInt()
95-
{
96-
const auto isSlate = SysProc::GetSlateState();
97-
if (isSlate)
98-
return 0; //it is not
99-
else
100-
{
101-
const auto isTabletPC = SysProc::GetTabletPCState();
102-
if (isTabletPC)
103-
return 1;
104-
else
105-
return -1;
106-
}
107-
}
108-
109-
//0 = normal mode, 1 = slate mode
110-
int UserInteractionMode::GetSlateState()
111-
{
112-
const auto ver = GetSlateStateInt();
113-
114-
if (ver == -1)
115-
return 0;
116-
117-
return ver;
118-
}
119-
120-
int UserInteractionMode::GetDockState()
121-
{
122-
return SysProc::GetDockState();
123-
}
124-
}
11+
Windows::UI::Xaml::DispatcherTimer m_timer;
12+
int currentSlateState = 0;
13+
14+
NTSTATUS NTAPI WnfCallback(const ULONG64 state_name, void* p2, void* p3, void* callbackContext, void* buffer, ULONG bufferSize)
15+
{
16+
if (((UserInteractionMode*)callbackContext)->IsSubscribed())
17+
((UserInteractionMode*)callbackContext)->InvokeTabletModeChange();
18+
19+
return 0;
20+
}
21+
22+
void UserInteractionMode::InvokeTabletModeChange()
23+
{
24+
const auto inter = GetUserInteractionMode();
25+
event_userInteractionModeChanged(*this, inter);
26+
}
27+
28+
event_token UserInteractionMode::UserInteractionModeChanged(Windows::Foundation::EventHandler<UserInteractionType> const& handler)
29+
{
30+
if (numSub_userInteractionModeChangedEvent++ == 0)
31+
{
32+
isSubscribed = true;
33+
currentSlateState = GetSlateState();
34+
35+
Windows::Foundation::TimeSpan dur(2500000L);
36+
m_timer.Interval(dur);
37+
m_timer.Tick([this](Windows::Foundation::IInspectable const&, Windows::Foundation::IInspectable const&)
38+
{
39+
const auto curSlat = GetSlateState();
40+
if (curSlat != currentSlateState)
41+
{
42+
currentSlateState = curSlat;
43+
InvokeTabletModeChange();
44+
}
45+
else
46+
currentSlateState = curSlat;
47+
});
48+
m_timer.Start();
49+
50+
if (firstTimeSubscription)
51+
{
52+
Wnf::SubscribeWnf(WNF_TMCN_ISTABLETMODE, WnfCallback, (intptr_t)this);
53+
firstTimeSubscription = false;
54+
}
55+
}
56+
57+
return event_userInteractionModeChanged.add(handler);
58+
}
59+
60+
void UserInteractionMode::UserInteractionModeChanged(winrt::event_token const& token) noexcept
61+
{
62+
if (--numSub_userInteractionModeChangedEvent == 0)
63+
{
64+
//Wnf::UnsubscribeWnf(WnfCallback);
65+
isSubscribed = false;
66+
m_timer.Stop();
67+
}
68+
69+
event_userInteractionModeChanged.remove(token);
70+
}
71+
72+
UserInteractionType UserInteractionMode::GetUserInteractionMode()
73+
{
74+
bool res = Wnf::IsTabletMode();
75+
bool slate = GetSlateState();
76+
77+
if (res)
78+
{
79+
if (slate)
80+
return UserInteractionType::TouchInTabletMode;
81+
else
82+
return UserInteractionType::MouseInTabletMode;
83+
}
84+
else
85+
{
86+
if (slate)
87+
return UserInteractionType::TouchInDesktopMode;
88+
else
89+
return UserInteractionType::MouseInDesktopMode;
90+
}
91+
}
92+
93+
//0 = normal mode, 1 = slate mode, -1 = not a slate
94+
int UserInteractionMode::GetSlateStateInt()
95+
{
96+
const auto isSlate = SysProc::GetSlateState();
97+
if (isSlate)
98+
return 0; //it is not
99+
else
100+
{
101+
const auto isTabletPC = SysProc::GetTabletPCState();
102+
if (isTabletPC)
103+
return 1;
104+
else
105+
return -1;
106+
}
107+
}
108+
109+
//0 = normal mode, 1 = slate mode
110+
int UserInteractionMode::GetSlateState()
111+
{
112+
const auto ver = GetSlateStateInt();
113+
114+
if (ver == -1)
115+
return 0;
116+
117+
return ver;
118+
}
119+
120+
int UserInteractionMode::GetDockState()
121+
{
122+
return SysProc::GetDockState();
123+
}
124+
}

Files.Extensions/UserInteractionMode.h

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,37 @@
99

1010
namespace winrt::Files_Extensions::implementation
1111
{
12-
struct UserInteractionMode : UserInteractionModeT<UserInteractionMode>
13-
{
14-
UserInteractionMode()
15-
{
16-
Wnf::InitLib();
17-
SysProc::InitLib();
18-
}
12+
struct UserInteractionMode : UserInteractionModeT<UserInteractionMode>
13+
{
14+
UserInteractionMode()
15+
{
16+
Wnf::InitLib();
17+
SysProc::InitLib();
18+
}
1919

20-
winrt::event_token UserInteractionModeChanged(Windows::Foundation::EventHandler<UserInteractionType> const& handler);
21-
void UserInteractionModeChanged(winrt::event_token const& token) noexcept;
20+
winrt::event_token UserInteractionModeChanged(Windows::Foundation::EventHandler<UserInteractionType> const& handler);
21+
void UserInteractionModeChanged(winrt::event_token const& token) noexcept;
2222

23-
UserInteractionType GetUserInteractionMode();
24-
int GetSlateState();
25-
int GetDockState();
23+
UserInteractionType GetUserInteractionMode();
24+
int GetSlateState();
25+
int GetDockState();
2626

27-
void InvokeTabletModeChange();
28-
bool IsSubscribed()
29-
{
30-
return isSubscribed;
31-
}
32-
private:
33-
int GetSlateStateInt();
34-
winrt::event<Windows::Foundation::EventHandler<UserInteractionType>> event_userInteractionModeChanged;
35-
int numSub_userInteractionModeChangedEvent = 0;
36-
bool firstTimeSubscription = true;
37-
bool isSubscribed = false;
38-
};
27+
void InvokeTabletModeChange();
28+
bool IsSubscribed()
29+
{
30+
return isSubscribed;
31+
}
32+
private:
33+
int GetSlateStateInt();
34+
winrt::event<Windows::Foundation::EventHandler<UserInteractionType>> event_userInteractionModeChanged;
35+
int numSub_userInteractionModeChangedEvent = 0;
36+
bool firstTimeSubscription = true;
37+
bool isSubscribed = false;
38+
};
3939
}
4040
namespace winrt::Files_Extensions::factory_implementation
4141
{
42-
struct UserInteractionMode : UserInteractionModeT<UserInteractionMode, implementation::UserInteractionMode>
43-
{
44-
};
42+
struct UserInteractionMode : UserInteractionModeT<UserInteractionMode, implementation::UserInteractionMode>
43+
{
44+
};
4545
}
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
namespace Files_Extensions
22
{
3-
enum UserInteractionType
4-
{
5-
MouseInDesktopMode = 0,
6-
TouchInDesktopMode = 1,
7-
MouseInTabletMode = 2,
8-
TouchInTabletMode = 3
9-
};
3+
enum UserInteractionType
4+
{
5+
MouseInDesktopMode = 0,
6+
TouchInDesktopMode = 1,
7+
MouseInTabletMode = 2,
8+
TouchInTabletMode = 3
9+
};
1010

11-
[default_interface]
12-
runtimeclass UserInteractionMode
13-
{
14-
UserInteractionMode();
15-
event Windows.Foundation.EventHandler<UserInteractionType> UserInteractionModeChanged;
16-
UserInteractionType GetUserInteractionMode();
17-
Int32 GetSlateState();
18-
Int32 GetDockState();
19-
}
11+
[default_interface]
12+
runtimeclass UserInteractionMode
13+
{
14+
UserInteractionMode();
15+
event Windows.Foundation.EventHandler<UserInteractionType> UserInteractionModeChanged;
16+
UserInteractionType GetUserInteractionMode();
17+
Int32 GetSlateState();
18+
Int32 GetDockState();
19+
}
2020
}

Files.Extensions/Wnf.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#include "Wnf.h"
33
#include "TEBProc.h"
44

5-
65
RtlSubscribeWnfStateChangeNotification pRtlSubscribeWnfStateChangeNotification;
76
RtlUnsubscribeWnfStateChangeNotification pRtlUnsubscribeWnfStateChangeNotification;
87
NtQueryWnfStateData pNtQueryWnfStateData;

Files.Extensions/pch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
#include "pch.h"
1+
#include "pch.h"

0 commit comments

Comments
 (0)