diff --git a/GlosSITarget/.clang-format b/GlosSITarget/.clang-format
new file mode 100644
index 0000000..fdf9b92
--- /dev/null
+++ b/GlosSITarget/.clang-format
@@ -0,0 +1,6 @@
+UseTab: false
+IndentWidth: 4
+BreakBeforeBraces: "Stroustrup"
+AllowShortIfStatementsOnASingleLine: false
+IndentCaseLabels: false
+ColumnLimit: 0
\ No newline at end of file
diff --git a/GlosSITarget/GlosSITarget.vcxproj b/GlosSITarget/GlosSITarget.vcxproj
index 0f65b15..ec8d5a7 100644
--- a/GlosSITarget/GlosSITarget.vcxproj
+++ b/GlosSITarget/GlosSITarget.vcxproj
@@ -168,6 +168,7 @@
true
+
diff --git a/GlosSITarget/GlosSITarget.vcxproj.filters b/GlosSITarget/GlosSITarget.vcxproj.filters
index 45e16d3..ad2f87d 100644
--- a/GlosSITarget/GlosSITarget.vcxproj.filters
+++ b/GlosSITarget/GlosSITarget.vcxproj.filters
@@ -37,5 +37,6 @@
+
\ No newline at end of file
diff --git a/GlosSITarget/SteamTarget.cpp b/GlosSITarget/SteamTarget.cpp
index 19de660..0214a24 100644
--- a/GlosSITarget/SteamTarget.cpp
+++ b/GlosSITarget/SteamTarget.cpp
@@ -1,12 +1,28 @@
+/*
+Copyright 2021 Peter Repukat - FlatspotSoftware
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
#include "SteamTarget.h"
#include
-SteamTarget::SteamTarget(int argc, char* argv[]) : window_([this] { run_ = false; }) {
-
+SteamTarget::SteamTarget(int argc, char *argv[]) : window_([this] { run_ = false; })
+{
}
-int SteamTarget::run() {
+int SteamTarget::run()
+{
run_ = true;
window_.setFpsLimit(90);
while (run_) {
diff --git a/GlosSITarget/SteamTarget.h b/GlosSITarget/SteamTarget.h
index a3ec8eb..7388af1 100644
--- a/GlosSITarget/SteamTarget.h
+++ b/GlosSITarget/SteamTarget.h
@@ -1,15 +1,28 @@
+/*
+Copyright 2021 Peter Repukat - FlatspotSoftware
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
#pragma once
#include "TargetWindow.h"
-class SteamTarget
-{
-public:
- explicit SteamTarget(int argc, char* argv[]);
+class SteamTarget {
+ public:
+ explicit SteamTarget(int argc, char *argv[]);
int run();
-private:
+ private:
bool run_ = false;
TargetWindow window_;
};
-
diff --git a/GlosSITarget/TargetWindow.cpp b/GlosSITarget/TargetWindow.cpp
index 268c321..c5e5fb8 100644
--- a/GlosSITarget/TargetWindow.cpp
+++ b/GlosSITarget/TargetWindow.cpp
@@ -1,3 +1,18 @@
+/*
+Copyright 2021 Peter Repukat - FlatspotSoftware
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
#include "TargetWindow.h"
#include
@@ -9,56 +24,59 @@
#include
#endif
-
TargetWindow::TargetWindow(std::function on_close) : on_close_(std::move(on_close))
{
- window_.create(sf::VideoMode::getDesktopMode(), "GlosSITarget", sf::Style::None);
+ window_.create(sf::VideoMode::getDesktopMode(), "GlosSITarget", sf::Style::None);
window_.setActive(true);
-#ifdef _WIN32
- HWND hwnd = window_.getSystemHandle();
- MARGINS margins;
- margins.cxLeftWidth = -1;
- DwmExtendFrameIntoClientArea(hwnd, &margins);
-
- // window clickthough.
- SetWindowLong(hwnd, GWL_EXSTYLE, WS_EX_LAYERED | WS_EX_TRANSPARENT | WS_EX_TOPMOST);
-
- // always on top
- SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
+#ifdef _WIN32
+ HWND hwnd = window_.getSystemHandle();
+ MARGINS margins;
+ margins.cxLeftWidth = -1;
+ DwmExtendFrameIntoClientArea(hwnd, &margins);
+ // always on top
+ SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
#endif
+
+ setClickThrough(true);
}
void TargetWindow::setFpsLimit(unsigned int fps_limit)
{
- window_.setFramerateLimit(fps_limit);
+ window_.setFramerateLimit(fps_limit);
}
void TargetWindow::setClickThrough(bool click_through)
{
-
-}
+#ifdef _WIN32
+ HWND hwnd = window_.getSystemHandle();
+ if (click_through) {
+ SetWindowLong(hwnd, GWL_EXSTYLE, WS_EX_LAYERED | WS_EX_TRANSPARENT | WS_EX_TOPMOST);
+ }
+ else {
+ SetWindowLong(hwnd, GWL_EXSTYLE, WS_EX_LAYERED);
+ }
+#endif
+}
void TargetWindow::update()
{
- sf::Event event{};
- while (window_.pollEvent(event))
- {
- if (event.type == sf::Event::Closed)
- {
- window_.close();
- on_close_();
- }
- }
- window_.clear(sf::Color::Transparent);
- //window_.clear(sf::Color(255,0,0,1));
- window_.display();
+ sf::Event event{};
+ while (window_.pollEvent(event)) {
+ if (event.type == sf::Event::Closed) {
+ window_.close();
+ on_close_();
+ }
+ }
+ window_.clear(sf::Color::Transparent);
+ //window_.clear(sf::Color(255,0,0,1));
+ window_.display();
}
void TargetWindow::close()
{
- window_.close();
- on_close_();
+ window_.close();
+ on_close_();
}
diff --git a/GlosSITarget/TargetWindow.h b/GlosSITarget/TargetWindow.h
index 1ebbdeb..ddacd19 100644
--- a/GlosSITarget/TargetWindow.h
+++ b/GlosSITarget/TargetWindow.h
@@ -1,20 +1,33 @@
+/*
+Copyright 2021 Peter Repukat - FlatspotSoftware
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
#pragma once
#include
#include
-class TargetWindow
-{
-public:
- explicit TargetWindow(std::function on_close = [](){});
+class TargetWindow {
+ public:
+ explicit TargetWindow(std::function on_close = []() {});
void setFpsLimit(unsigned int fps_limit);
void setClickThrough(bool click_through);
void update();
void close();
-private:
+ private:
const std::function on_close_;
sf::RenderWindow window_;
};
-
diff --git a/GlosSITarget/main.cpp b/GlosSITarget/main.cpp
index 337b0e5..e78870a 100644
--- a/GlosSITarget/main.cpp
+++ b/GlosSITarget/main.cpp
@@ -32,7 +32,8 @@ limitations under the License.
// return SteamTarget::exec();
//}
-int main(int argc, char* argv[]) {
- SteamTarget target(argc, argv);
- return target.run();
+int main(int argc, char *argv[])
+{
+ SteamTarget target(argc, argv);
+ return target.run();
}
\ No newline at end of file