mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 10:16:24 +02:00
Fix for different per-monitor scaling (#657)
* Use DPIAware::DEFAULT_DPI * Make runner DPI-unaware, since it doesn't need to use a Per Monitor V2 DPI. * Programmatically enable "Per Monitor V2 DPI" for the runner proccess and use a separate DPI-unaware thread for the corresponding API calls * Increase PCH memory limit for settings project * Address review issues * Draw zoneWindows properly scaled
This commit is contained in:
38
src/common/on_thread_executor.cpp
Normal file
38
src/common/on_thread_executor.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "pch.h"
|
||||
|
||||
#include "on_thread_executor.h"
|
||||
|
||||
OnThreadExecutor::OnThreadExecutor()
|
||||
:_worker_thread{[this]() { worker_thread(); }}
|
||||
{}
|
||||
|
||||
std::future<void> OnThreadExecutor::submit(task_t task) {
|
||||
auto future = task.get_future();
|
||||
std::lock_guard lock{_task_mutex};
|
||||
_task_queue.emplace(std::move(task));
|
||||
_task_cv.notify_one();
|
||||
return future;
|
||||
}
|
||||
|
||||
void OnThreadExecutor::worker_thread() {
|
||||
while(_active) {
|
||||
task_t task;
|
||||
{
|
||||
std::unique_lock task_lock{_task_mutex};
|
||||
_task_cv.wait(task_lock, [this] { return !_task_queue.empty() || !_active; });
|
||||
if(!_active) {
|
||||
break;
|
||||
}
|
||||
task = std::move(_task_queue.front());
|
||||
_task_queue.pop();
|
||||
}
|
||||
task();
|
||||
}
|
||||
}
|
||||
|
||||
OnThreadExecutor::~OnThreadExecutor() {
|
||||
_active = false;
|
||||
_task_cv.notify_one();
|
||||
_worker_thread.join();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user