Compare commits

..

11 Commits

Author SHA1 Message Date
Jonathan Rubenstein
25c88a1c6c [doc] faq: Correct misinformed question about mouse warp issue 2021-07-17 15:20:22 +10:00
Geoffrey McRae
7decb58bf7 [host] windows: fix build on Linux due to case sensitive filenames 2021-07-17 15:05:32 +10:00
Geoffrey McRae
d1ec19b30b [host] windows: fix delayExecution order of magnitude bug 2021-07-17 15:02:58 +10:00
Geoffrey McRae
74468cf799 [host] windows: remove accidental addition of some junk 2021-07-17 15:02:36 +10:00
Geoffrey McRae
411a6b1e49 [host] windows: add delayExecution function for more accurate sleeps
This change not only exposes and allows use of NtDelayExecution, but
also moves the code to set the system timer resolution.
2021-07-17 14:55:22 +10:00
Geoffrey McRae
e228165ff9 [host] windows: fix system timer resolution message units
ZwSetTimerResolution works in units of 100ns
2021-07-17 14:31:31 +10:00
Geoffrey McRae
d615514799 [host] windows: do not callback from the mouse hook context
The windows hook WH_MOUSE_LL is called in such a way that any delay in
processing causes a system wide stall. This change spawns an extra
thread which waits on an event set by the hook which is then used to
call the callback with an artifical limit of 1000Hz.
2021-07-17 14:03:52 +10:00
Jonathan Rubenstein
ed717351cf [doc] faq: Partial revert of fa871e9 to include registry hack
Expected to be fixed in B5
2021-07-16 00:47:22 +10:00
Jonathan Rubenstein
4658244686 [doc] build: Revise client build dependencies for B4 2021-07-16 00:47:22 +10:00
Quantum
48ae5c69f4 [client] wayland: fix typo in warp usage
The unwanted ! was introduced in 4b99bba200.
This basically caused warp to never be used.
2021-07-15 08:40:36 +10:00
Geoffrey McRae
4d065d577b [obs] call debug_init() to initialize debug print
Fixes a segfault reported in discord, DEBUG_* macros are not available
until `debug_init()` has been called as of commit
1effd5fddc
2021-07-13 07:42:25 +10:00
9 changed files with 181 additions and 31 deletions

View File

@@ -444,7 +444,7 @@ void waylandWarpPointer(int x, int y, bool exiting)
INTERLOCKED_SECTION(wlWm.confineLock,
{
if (!wlWm.lockedPointer)
if (wlWm.lockedPointer)
{
LG_UNLOCK(wlWm.confineLock);
return;

View File

@@ -59,14 +59,12 @@ Required Dependencies
- libgl-dev
- libfontconfig1-dev
- libgmp-dev
- libsdl2-dev
- libsdl2-ttf-dev
- libspice-protocol-dev
- make
- nettle-dev
- pkg-config
.. _may_be_disabled:
.. _client_deps_may_be_disabled:
May be disabled
<<<<<<<<<<<<<<<
@@ -83,6 +81,7 @@ feature is disabled when running :ref:`cmake <client_building>`.
- libx11-dev
- libxfixes-dev
- libxi-dev
- libxinerama-dev
- libxss-dev
- Disable with ``cmake -DENABLE_WAYLAND=no ..``
@@ -91,11 +90,33 @@ feature is disabled when running :ref:`cmake <client_building>`.
- libwayland-dev
- wayland-protocols
You can fetch these dependencies on Debian systems with the following command:
.. _client_deps_deprecated:
Deprecated
<<<<<<<<<<
These dependencies may be used, but are not required, and will be removed
in the future.
- Enable with ``cmake -DENABLE_SDL=yes ..``
- libsdl2-dev
- libsdl2-ttf-dev
.. _client_fetching_with_apt:
Fetching with APT
^^^^^^^^^^^^^^^^^
You can fetch these dependencies with the following command:
``apt-get install binutils-dev cmake fonts-freefont-ttf libfontconfig1-dev
libsdl2-dev libsdl2-ttf-dev libspice-protocol-dev libx11-dev nettle-dev
wayland-protocols``
libegl-dev libspice-protocol-dev nettle-dev libx11-dev libxi-dev libxinerama-dev
libxss-dev libwayland-dev wayland-protocols``
You may omit some dependencies, if you disable the feature which requires them
when running :ref:`cmake <client_building>`.
(See :ref:`client_deps_may_be_disabled`)
.. _client_building:

View File

@@ -88,13 +88,20 @@ The mouse is jumpy, slow, laggy when using SPICE
Please be sure to install the SPICE guest tools from
https://www.spice-space.org/download.html#windows-binaries.
.. _the_mouse_doesnt_stay_aligned_with_the_host.:
.. _mouse_desync_when_entering:
The mouse doesn't stay aligned with the host.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The mouse position is wrong when entering the window
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is intentional. The host's mouse no longer interacts with your operating
system, and is completely captured by Looking Glass.
This is due to windows mouse acceleration, it can be disabled by
following one of these methods:
- Disabling pointer precision (Control Panel > Mouse > Pointer Options
> Uncheck Enhance pointer precision)
- By changing the acceleration behavior with the following registry
magic:
http://donewmouseaccel.blogspot.com.au/2010/03/markc-windows-7-mouse-acceleration-fix.html
(Contrary to the title this works just fine on Windows 10)
.. _the_cursor_position_doesnt_update_until_i_click:

View File

@@ -10,6 +10,7 @@ add_library(platform_Windows STATIC
src/service.c
src/mousehook.c
src/force_compose.c
src/delay.c
)
# allow use of functions for Windows Vista or later

View File

@@ -0,0 +1,34 @@
/**
* Looking Glass
* Copyright (C) 2017-2021 The Looking Glass Authors
* https://looking-glass.io
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program 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 GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc., 59
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <windows.h>
typedef NTSTATUS (__stdcall *ZwSetTimerResolution_t)(ULONG RequestedResolution,
BOOLEAN Set, PULONG ActualResolution);
extern ZwSetTimerResolution_t ZwSetTimerResolution;
typedef NTSTATUS (__stdcall *NtDelayExecution_t)(BOOL Alertable,
PLARGE_INTEGER DelayInterval);
extern NtDelayExecution_t NtDelayExecution;
void delayInit(void);
// like sleep but more accurate
void delayExecution(float ms);

View File

@@ -0,0 +1,49 @@
/**
* Looking Glass
* Copyright (C) 2017-2021 The Looking Glass Authors
* https://looking-glass.io
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program 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 GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc., 59
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "windows/delay.h"
#include "common/debug.h"
NtDelayExecution_t NtDelayExecution;
ZwSetTimerResolution_t ZwSetTimerResolution;
void delayInit(void)
{
HMODULE ntdll = GetModuleHandle("ntdll.dll");
NtDelayExecution = (NtDelayExecution_t)
GetProcAddress(ntdll, "NtDelayExecution");
// Increase the timer resolution
ZwSetTimerResolution = (ZwSetTimerResolution_t)
GetProcAddress(ntdll, "ZwSetTimerResolution");
if (ZwSetTimerResolution)
{
ULONG actualResolution;
ZwSetTimerResolution(1, true, &actualResolution);
DEBUG_INFO("System timer resolution: %lu ns", actualResolution * 100);
}
}
void delayExecution(float ms)
{
LARGE_INTEGER interval = { .QuadPart = -1 * (int)(ms * 10000.0f) };
NtDelayExecution(FALSE, &interval);
}

View File

@@ -19,6 +19,7 @@
*/
#include "windows/mousehook.h"
#include "windows/delay.h"
#include "common/windebug.h"
#include "platform.h"
@@ -31,8 +32,8 @@ struct mouseHook
HHOOK hook;
MouseHookFn callback;
int x, y;
HANDLE event;
HANDLE thread;
HANDLE event , updateEvent;
HANDLE thread, updateThread;
};
static struct mouseHook mouseHook = { 0 };
@@ -85,6 +86,31 @@ static VOID WINAPI winEventProc(HWINEVENTHOOK hWinEventHook, DWORD event,
}
}
static DWORD WINAPI updateThreadProc(LPVOID lParam)
{
HANDLE events[2] = {
mouseHook.event,
mouseHook.updateEvent
};
while(true)
{
switch(WaitForMultipleObjects(2, events, FALSE, INFINITE))
{
case WAIT_OBJECT_0:
DEBUG_INFO("Mouse hook update thread received quit request");
return 0;
case WAIT_OBJECT_0 + 1:
mouseHook.callback(mouseHook.x, mouseHook.y);
// limit this to 1000Hz, who has a mouse that updates faster anyway?
delayExecution(1.0f);
break;
}
}
}
static DWORD WINAPI threadProc(LPVOID lParam) {
if (mouseHook.installed)
{
@@ -143,11 +169,28 @@ void mouseHook_install(MouseHookFn callback)
mouseHook.event = CreateEventA(NULL, FALSE, FALSE, NULL);
if (!mouseHook.event)
{
DEBUG_WINERROR("Failed to create mouse hook uninstall event", GetLastError());
DEBUG_WINERROR("Failed to create mouse hook uninstall event",
GetLastError());
return;
}
}
mouseHook.thread = CreateThread(NULL, 0, threadProc, callback, 0, NULL);
if (!mouseHook.updateEvent)
{
mouseHook.updateEvent = CreateEventA(NULL, FALSE, FALSE, NULL);
if (!mouseHook.event)
{
DEBUG_WINERROR("Failed to create mouse hook update event",
GetLastError());
return;
}
}
mouseHook.thread =
CreateThread(NULL, 0, threadProc, callback, 0, NULL);
mouseHook.updateThread =
CreateThread(NULL, 0, updateThreadProc, 0, 0, NULL);
}
void mouseHook_remove(void)
@@ -156,8 +199,10 @@ void mouseHook_remove(void)
return;
SetEvent(mouseHook.event);
WaitForSingleObject(mouseHook.thread, INFINITE);
WaitForSingleObject(mouseHook.thread , INFINITE);
WaitForSingleObject(mouseHook.updateThread, INFINITE);
CloseHandle(mouseHook.thread);
CloseHandle(mouseHook.updateThread);
}
static LRESULT WINAPI mouseHook_hook(int nCode, WPARAM wParam, LPARAM lParam)
@@ -169,7 +214,7 @@ static LRESULT WINAPI mouseHook_hook(int nCode, WPARAM wParam, LPARAM lParam)
{
mouseHook.x = msg->pt.x;
mouseHook.y = msg->pt.y;
mouseHook.callback(msg->pt.x, msg->pt.y);
SetEvent(mouseHook.updateEvent);
}
}
return CallNextHookEx(mouseHook.hook, nCode, wParam, lParam);

View File

@@ -20,6 +20,7 @@
#include "platform.h"
#include "service.h"
#include "windows/delay.h"
#include "windows/mousehook.h"
#include <windows.h>
@@ -61,10 +62,6 @@ struct AppState
static struct AppState app = {0};
HWND MessageHWND;
// undocumented API to adjust the system timer resolution (yes, its a nasty hack)
typedef NTSTATUS (__stdcall *ZwSetTimerResolution_t)(ULONG RequestedResolution, BOOLEAN Set, PULONG ActualResolution);
static ZwSetTimerResolution_t ZwSetTimerResolution = NULL;
// linux mingw64 is missing this
#ifndef MSGFLT_RESET
#define MSGFLT_RESET (0)
@@ -504,7 +501,7 @@ void boostPriority(void)
bool app_init(void)
{
const char * logFile = option_get_string("os", "logFile" );
const char * logFile = option_get_string("os", "logFile");
// redirect stderr to a file
if (logFile && strcmp(logFile, "stderr") != 0)
@@ -513,14 +510,7 @@ bool app_init(void)
// always flush stderr
setbuf(stderr, NULL);
// Increase the timer resolution
ZwSetTimerResolution = (ZwSetTimerResolution_t)GetProcAddress(GetModuleHandle("ntdll.dll"), "ZwSetTimerResolution");
if (ZwSetTimerResolution)
{
ULONG actualResolution;
ZwSetTimerResolution(1, true, &actualResolution);
DEBUG_INFO("System timer resolution: %.2f ns", (float)actualResolution / 100.0f);
}
delayInit();
// get the performance frequency for spinlocks
QueryPerformanceFrequency(&app.perfFreq);

View File

@@ -22,6 +22,8 @@
#include <common/version.h>
#include <stdio.h>
#include "common/debug.h"
#ifdef _WIN32
#undef EXPORT
#define EXPORT __declspec(dllexport)
@@ -38,6 +40,7 @@ extern struct obs_source_info lg_source;
MODULE_EXPORT bool obs_module_load(void)
{
debug_init();
printf("Looking Glass OBS Client (%s)\n", BUILD_VERSION);
obs_register_source(&lg_source);
return true;