mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-11-17 07:28:44 +00:00
Compare commits
11 Commits
B4-rc3
...
Release/B4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
25c88a1c6c | ||
|
|
7decb58bf7 | ||
|
|
d1ec19b30b | ||
|
|
74468cf799 | ||
|
|
411a6b1e49 | ||
|
|
e228165ff9 | ||
|
|
d615514799 | ||
|
|
ed717351cf | ||
|
|
4658244686 | ||
|
|
48ae5c69f4 | ||
|
|
4d065d577b |
@@ -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;
|
||||
|
||||
@@ -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:
|
||||
|
||||
17
doc/faq.rst
17
doc/faq.rst
@@ -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:
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
34
host/platform/Windows/include/windows/delay.h
Normal file
34
host/platform/Windows/include/windows/delay.h
Normal 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);
|
||||
49
host/platform/Windows/src/delay.c
Normal file
49
host/platform/Windows/src/delay.c
Normal 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);
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user