Split keyboard and mouse interceptor to separate operations to avoid mouse lagg during startup / shutdown.
This commit is contained in:
parent
0807b5f5f9
commit
be49058e8c
7 changed files with 76 additions and 15 deletions
|
@ -29,8 +29,12 @@ namespace SafeExamBrowser.Contracts.I18n
|
|||
SplashScreen_RestoreWorkingArea,
|
||||
SplashScreen_ShutdownProcedure,
|
||||
SplashScreen_StartEventHandling,
|
||||
SplashScreen_StartKeyboardInterception,
|
||||
SplashScreen_StartMouseInterception,
|
||||
SplashScreen_StartupProcedure,
|
||||
SplashScreen_StopEventHandling,
|
||||
SplashScreen_StopKeyboardInterception,
|
||||
SplashScreen_StopMouseInterception,
|
||||
SplashScreen_StopProcessMonitoring,
|
||||
SplashScreen_StopWindowMonitoring,
|
||||
SplashScreen_TerminateBrowser,
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
|
||||
using SafeExamBrowser.Contracts.Behaviour;
|
||||
using SafeExamBrowser.Contracts.I18n;
|
||||
using SafeExamBrowser.Contracts.Logging;
|
||||
using SafeExamBrowser.Contracts.Monitoring;
|
||||
using SafeExamBrowser.Contracts.UserInterface;
|
||||
|
@ -14,40 +15,38 @@ using SafeExamBrowser.Contracts.WindowsApi;
|
|||
|
||||
namespace SafeExamBrowser.Core.Behaviour.Operations
|
||||
{
|
||||
public class DeviceInterceptionOperation : IOperation
|
||||
public class KeyboardInterceptorOperation : IOperation
|
||||
{
|
||||
private IKeyboardInterceptor keyboardInterceptor;
|
||||
private ILogger logger;
|
||||
private IMouseInterceptor mouseInterceptor;
|
||||
private INativeMethods nativeMethods;
|
||||
|
||||
public ISplashScreen SplashScreen { private get; set; }
|
||||
|
||||
public DeviceInterceptionOperation(
|
||||
public KeyboardInterceptorOperation(
|
||||
IKeyboardInterceptor keyboardInterceptor,
|
||||
ILogger logger,
|
||||
IMouseInterceptor mouseInterceptor,
|
||||
INativeMethods nativeMethods)
|
||||
{
|
||||
this.keyboardInterceptor = keyboardInterceptor;
|
||||
this.logger = logger;
|
||||
this.mouseInterceptor = mouseInterceptor;
|
||||
this.nativeMethods = nativeMethods;
|
||||
}
|
||||
|
||||
public void Perform()
|
||||
{
|
||||
logger.Info("Starting keyboard and mouse interception...");
|
||||
logger.Info("Starting keyboard interception...");
|
||||
SplashScreen.UpdateText(TextKey.SplashScreen_StartKeyboardInterception);
|
||||
|
||||
nativeMethods.RegisterKeyboardHook(keyboardInterceptor);
|
||||
nativeMethods.RegisterMouseHook(mouseInterceptor);
|
||||
|
||||
}
|
||||
|
||||
public void Revert()
|
||||
{
|
||||
logger.Info("Stopping keyboard and mouse interception...");
|
||||
logger.Info("Stopping keyboard interception...");
|
||||
SplashScreen.UpdateText(TextKey.SplashScreen_StopKeyboardInterception);
|
||||
|
||||
nativeMethods.DeregisterMouseHook(mouseInterceptor);
|
||||
nativeMethods.DeregisterKeyboardHook(keyboardInterceptor);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright (c) 2017 ETH Zürich, Educational Development and Technology (LET)
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
using SafeExamBrowser.Contracts.Behaviour;
|
||||
using SafeExamBrowser.Contracts.I18n;
|
||||
using SafeExamBrowser.Contracts.Logging;
|
||||
using SafeExamBrowser.Contracts.Monitoring;
|
||||
using SafeExamBrowser.Contracts.UserInterface;
|
||||
using SafeExamBrowser.Contracts.WindowsApi;
|
||||
|
||||
namespace SafeExamBrowser.Core.Behaviour.Operations
|
||||
{
|
||||
public class MouseInterceptorOperation : IOperation
|
||||
{
|
||||
private ILogger logger;
|
||||
private IMouseInterceptor mouseInterceptor;
|
||||
private INativeMethods nativeMethods;
|
||||
|
||||
public ISplashScreen SplashScreen { private get; set; }
|
||||
|
||||
public MouseInterceptorOperation(
|
||||
ILogger logger,
|
||||
IMouseInterceptor mouseInterceptor,
|
||||
INativeMethods nativeMethods)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.mouseInterceptor = mouseInterceptor;
|
||||
this.nativeMethods = nativeMethods;
|
||||
}
|
||||
|
||||
public void Perform()
|
||||
{
|
||||
logger.Info("Starting mouse interception...");
|
||||
SplashScreen.UpdateText(TextKey.SplashScreen_StartMouseInterception);
|
||||
|
||||
nativeMethods.RegisterMouseHook(mouseInterceptor);
|
||||
}
|
||||
|
||||
public void Revert()
|
||||
{
|
||||
logger.Info("Stopping mouse interception...");
|
||||
SplashScreen.UpdateText(TextKey.SplashScreen_StopMouseInterception);
|
||||
|
||||
nativeMethods.DeregisterMouseHook(mouseInterceptor);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,14 +13,14 @@ using SafeExamBrowser.Contracts.UserInterface;
|
|||
|
||||
namespace SafeExamBrowser.Core.Behaviour.Operations
|
||||
{
|
||||
public class EventControllerOperation : IOperation
|
||||
public class RuntimeControllerOperation : IOperation
|
||||
{
|
||||
private ILogger logger;
|
||||
private IRuntimeController controller;
|
||||
|
||||
public ISplashScreen SplashScreen { private get; set; }
|
||||
|
||||
public EventControllerOperation(IRuntimeController controller, ILogger logger)
|
||||
public RuntimeControllerOperation(IRuntimeController controller, ILogger logger)
|
||||
{
|
||||
this.controller = controller;
|
||||
this.logger = logger;
|
|
@ -14,8 +14,12 @@
|
|||
<SplashScreen_RestoreWorkingArea>Restoring working area</SplashScreen_RestoreWorkingArea>
|
||||
<SplashScreen_ShutdownProcedure>Initiating shutdown procedure</SplashScreen_ShutdownProcedure>
|
||||
<SplashScreen_StartEventHandling>Starting event handling</SplashScreen_StartEventHandling>
|
||||
<SplashScreen_StartKeyboardInterception>Starting keyboard interception</SplashScreen_StartKeyboardInterception>
|
||||
<SplashScreen_StartMouseInterception>Starting mouse interception</SplashScreen_StartMouseInterception>
|
||||
<SplashScreen_StartupProcedure>Initiating startup procedure</SplashScreen_StartupProcedure>
|
||||
<SplashScreen_StopEventHandling>Stopping event handling</SplashScreen_StopEventHandling>
|
||||
<SplashScreen_StopKeyboardInterception>Stopping keyboard interception</SplashScreen_StopKeyboardInterception>
|
||||
<SplashScreen_StopMouseInterception>Stopping mouse interception</SplashScreen_StopMouseInterception>
|
||||
<SplashScreen_StopProcessMonitoring>Stopping process monitoring</SplashScreen_StopProcessMonitoring>
|
||||
<SplashScreen_StopWindowMonitoring>Stopping window monitoring</SplashScreen_StopWindowMonitoring>
|
||||
<SplashScreen_TerminateBrowser>Terminating browser</SplashScreen_TerminateBrowser>
|
||||
|
|
|
@ -58,10 +58,11 @@
|
|||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Behaviour\Operations\DeviceInterceptionOperation.cs" />
|
||||
<Compile Include="Behaviour\Operations\KeyboardInterceptorOperation.cs" />
|
||||
<Compile Include="Behaviour\Operations\MouseInterceptorOperation.cs" />
|
||||
<Compile Include="Behaviour\RuntimeController.cs" />
|
||||
<Compile Include="Behaviour\Operations\BrowserOperation.cs" />
|
||||
<Compile Include="Behaviour\Operations\EventControllerOperation.cs" />
|
||||
<Compile Include="Behaviour\Operations\RuntimeControllerOperation.cs" />
|
||||
<Compile Include="Behaviour\Operations\ProcessMonitorOperation.cs" />
|
||||
<Compile Include="Behaviour\Operations\TaskbarOperation.cs" />
|
||||
<Compile Include="Behaviour\Operations\WindowMonitorOperation.cs" />
|
||||
|
|
|
@ -77,13 +77,14 @@ namespace SafeExamBrowser
|
|||
StartupController = new StartupController(logger, settings, text, uiFactory);
|
||||
|
||||
StartupOperations = new Queue<IOperation>();
|
||||
StartupOperations.Enqueue(new DeviceInterceptionOperation(keyboardInterceptor, logger, mouseInterceptor, nativeMethods));
|
||||
StartupOperations.Enqueue(new KeyboardInterceptorOperation(keyboardInterceptor, logger, nativeMethods));
|
||||
StartupOperations.Enqueue(new WindowMonitorOperation(logger, windowMonitor));
|
||||
StartupOperations.Enqueue(new ProcessMonitorOperation(logger, processMonitor));
|
||||
StartupOperations.Enqueue(new WorkingAreaOperation(logger, Taskbar, workingArea));
|
||||
StartupOperations.Enqueue(new TaskbarOperation(logger, settings, Taskbar, text, uiFactory));
|
||||
StartupOperations.Enqueue(new BrowserOperation(browserController, browserInfo, logger, Taskbar, uiFactory));
|
||||
StartupOperations.Enqueue(new EventControllerOperation(runtimeController, logger));
|
||||
StartupOperations.Enqueue(new RuntimeControllerOperation(runtimeController, logger));
|
||||
StartupOperations.Enqueue(new MouseInterceptorOperation(logger, mouseInterceptor, nativeMethods));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue