aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/platform/MSWindowsDesks.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/platform/MSWindowsDesks.cpp')
-rw-r--r--src/lib/platform/MSWindowsDesks.cpp25
1 files changed, 9 insertions, 16 deletions
diff --git a/src/lib/platform/MSWindowsDesks.cpp b/src/lib/platform/MSWindowsDesks.cpp
index 768ccb4..d126e13 100644
--- a/src/lib/platform/MSWindowsDesks.cpp
+++ b/src/lib/platform/MSWindowsDesks.cpp
@@ -3,11 +3,11 @@
* Copyright (C) 2018 Debauchee Open Source Group
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2004 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package 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
@@ -27,9 +27,7 @@
#include "arch/win32/ArchMiscWindows.h"
#include "base/Log.h"
#include "base/IEventQueue.h"
-#include "base/IJob.h"
#include "base/TMethodEventJob.h"
-#include "base/TMethodJob.h"
#include "base/IEventQueue.h"
#include <malloc.h>
@@ -97,10 +95,9 @@
// MSWindowsDesks
//
-MSWindowsDesks::MSWindowsDesks(
- bool isPrimary, bool noHooks,
+MSWindowsDesks::MSWindowsDesks(bool isPrimary, bool noHooks,
const IScreenSaver* screensaver, IEventQueue* events,
- IJob* updateKeys, bool stopOnDeskSwitch) :
+ const std::function<void()>& updateKeys, bool stopOnDeskSwitch) :
m_isPrimary(isPrimary),
m_noHooks(noHooks),
m_isOnScreen(m_isPrimary),
@@ -130,7 +127,6 @@ MSWindowsDesks::~MSWindowsDesks()
disable();
destroyClass(m_deskClass);
destroyCursor(m_cursor);
- delete m_updateKeys;
}
void
@@ -602,13 +598,11 @@ MSWindowsDesks::deskLeave(Desk* desk, HKL keyLayout)
}
}
-void
-MSWindowsDesks::deskThread(void* vdesk)
+void MSWindowsDesks::desk_thread(Desk* desk)
{
MSG msg;
// use given desktop for this thread
- Desk* desk = static_cast<Desk*>(vdesk);
desk->m_threadID = GetCurrentThreadId();
desk->m_window = NULL;
desk->m_foregroundWindow = NULL;
@@ -709,7 +703,7 @@ MSWindowsDesks::deskThread(void* vdesk)
}
case BARRIER_MSG_SYNC_KEYS:
- m_updateKeys->run();
+ m_updateKeys();
break;
case BARRIER_MSG_SCREENSAVER:
@@ -752,8 +746,7 @@ MSWindowsDesks::Desk* MSWindowsDesks::addDesk(const std::string& name, HDESK hde
desk->m_name = name;
desk->m_desk = hdesk;
desk->m_targetID = GetCurrentThreadId();
- desk->m_thread = new Thread(new TMethodJob<MSWindowsDesks>(
- this, &MSWindowsDesks::deskThread, desk));
+ desk->m_thread = new Thread([this, desk]() { desk_thread(desk); });
waitForDesk();
m_desks.insert(std::make_pair(name, desk));
return desk;
@@ -793,7 +786,7 @@ MSWindowsDesks::checkDesk()
desk = index->second;
}
- // if we are told to shut down on desk switch, and this is not the
+ // if we are told to shut down on desk switch, and this is not the
// first switch, then shut down.
if (m_stopOnDeskSwitch && m_activeDesk != NULL && name != m_activeDeskName) {
LOG((CLOG_DEBUG "shutting down because of desk switch to \"%s\"", name.c_str()));
@@ -803,7 +796,7 @@ MSWindowsDesks::checkDesk()
// if active desktop changed then tell the old and new desk threads
// about the change. don't switch desktops when the screensaver is
- // active becaue we'd most likely switch to the screensaver desktop
+ // active because we'd most likely switch to the screensaver desktop
// which would have the side effect of forcing the screensaver to
// stop.
if (name != m_activeDeskName && !m_screensaver->isActive()) {