mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-07-16 04:12:03 +00:00
Compare commits
23 Commits
gnif-lates
...
gnif-lgmp-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e13a6e9350 | ||
|
|
c9845d3453 | ||
|
|
1f3051e81a | ||
|
|
4bb2c58fb6 | ||
|
|
e203bca480 | ||
|
|
8d7b45e240 | ||
|
|
66d8a9691e | ||
|
|
89ddab9d57 | ||
|
|
ffffff0740 | ||
|
|
c8edf1eaf3 | ||
|
|
938a2a6c22 | ||
|
|
e406b0fee8 | ||
|
|
79784fa44d | ||
|
|
a164c02f9a | ||
|
|
3aa6492760 | ||
|
|
0664e510a2 | ||
|
|
e4e211f07a | ||
|
|
bff890f635 | ||
|
|
2317801411 | ||
|
|
140de3199b | ||
|
|
c8f4898815 | ||
|
|
462f638c12 | ||
|
|
37bb89f490 |
@@ -263,6 +263,11 @@ void libdecor_pollWait(struct wl_display * display, int epollFd,
|
||||
}
|
||||
}
|
||||
|
||||
bool libdecor_configured(void)
|
||||
{
|
||||
return state.configured;
|
||||
}
|
||||
|
||||
WL_DesktopOps WLD_libdecor =
|
||||
{
|
||||
.name = "libdecor",
|
||||
@@ -277,5 +282,6 @@ WL_DesktopOps WLD_libdecor =
|
||||
.getSize = libdecor_getSize,
|
||||
.registryGlobalHandler = libdecor_registryGlobalHandler,
|
||||
.pollInit = libdecor_pollInit,
|
||||
.pollWait = libdecor_pollWait
|
||||
.pollWait = libdecor_pollWait,
|
||||
.configured = libdecor_configured
|
||||
};
|
||||
|
||||
@@ -304,6 +304,11 @@ void xdg_pollWait(struct wl_display * display, int epollFd,
|
||||
wl_display_cancel_read(display);
|
||||
}
|
||||
|
||||
bool xdg_configured(void)
|
||||
{
|
||||
return state.configured;
|
||||
}
|
||||
|
||||
WL_DesktopOps WLD_xdg =
|
||||
{
|
||||
.name = "xdg",
|
||||
@@ -318,5 +323,6 @@ WL_DesktopOps WLD_xdg =
|
||||
.getSize = xdg_getSize,
|
||||
.registryGlobalHandler = xdg_registryGlobalHandler,
|
||||
.pollInit = xdg_pollInit,
|
||||
.pollWait = xdg_pollWait
|
||||
.pollWait = xdg_pollWait,
|
||||
.configured = xdg_configured
|
||||
};
|
||||
|
||||
@@ -58,6 +58,8 @@ typedef struct WL_DesktopOps
|
||||
bool (*pollInit)(struct wl_display * display);
|
||||
|
||||
void (*pollWait)(struct wl_display * display, int epollFd, unsigned int time);
|
||||
|
||||
bool (*configured)(void);
|
||||
}
|
||||
WL_DesktopOps;
|
||||
|
||||
|
||||
@@ -60,6 +60,12 @@ wayland_generate(
|
||||
wayland_generate(
|
||||
"${WAYLAND_PROTOCOLS_BASE}/staging/xdg-activation/xdg-activation-v1.xml"
|
||||
"${CMAKE_BINARY_DIR}/wayland/wayland-xdg-activation-v1-client-protocol")
|
||||
wayland_generate(
|
||||
"${WAYLAND_PROTOCOLS_BASE}/staging/fractional-scale/fractional-scale-v1.xml"
|
||||
"${CMAKE_BINARY_DIR}/wayland/wayland-fractional-scale-v1-client-protocol")
|
||||
wayland_generate(
|
||||
"${WAYLAND_PROTOCOLS_BASE}/staging/content-type/content-type-v1.xml"
|
||||
"${CMAKE_BINARY_DIR}/wayland/wayland-content-type-v1-client-protocol")
|
||||
|
||||
target_link_libraries(wayland_protocol
|
||||
PkgConfig::WAYLAND
|
||||
|
||||
@@ -46,6 +46,9 @@ static void registryGlobalHandler(void * data, struct wl_registry * registry,
|
||||
else if (!strcmp(interface, wp_viewporter_interface.name))
|
||||
wlWm.viewporter = wl_registry_bind(wlWm.registry, name,
|
||||
&wp_viewporter_interface, 1);
|
||||
else if (!strcmp(interface, wp_fractional_scale_manager_v1_interface.name))
|
||||
wlWm.fractionalScaleManager = wl_registry_bind(wlWm.registry, name,
|
||||
&wp_fractional_scale_manager_v1_interface, 1);
|
||||
else if (!strcmp(interface, zwp_relative_pointer_manager_v1_interface.name))
|
||||
wlWm.relativePointerManager = wl_registry_bind(wlWm.registry, name,
|
||||
&zwp_relative_pointer_manager_v1_interface, 1);
|
||||
@@ -68,6 +71,9 @@ static void registryGlobalHandler(void * data, struct wl_registry * registry,
|
||||
else if (!strcmp(interface, xdg_activation_v1_interface.name))
|
||||
wlWm.xdgActivation = wl_registry_bind(wlWm.registry, name,
|
||||
&xdg_activation_v1_interface, 1);
|
||||
else if (!strcmp(interface, wp_content_type_manager_v1_interface.name))
|
||||
wlWm.contentTypeManager = wl_registry_bind(wlWm.registry, name,
|
||||
&wp_content_type_manager_v1_interface, 1);
|
||||
else if (wlWm.desktop->registryGlobalHandler(
|
||||
data, registry, name, interface, version))
|
||||
return;
|
||||
|
||||
@@ -71,7 +71,7 @@ static inline int waylandScaleCeil(struct WaylandScale scale)
|
||||
|
||||
static inline int waylandScaleMulInt(struct WaylandScale scale, int value)
|
||||
{
|
||||
return (int)(((int64_t)value * scale.num) / scale.den);
|
||||
return (int)(((int64_t)value * scale.num + scale.den / 2) / scale.den);
|
||||
}
|
||||
|
||||
static inline double waylandScaleToDouble(struct WaylandScale scale)
|
||||
|
||||
@@ -47,6 +47,8 @@
|
||||
#include "wayland-idle-inhibit-unstable-v1-client-protocol.h"
|
||||
#include "wayland-xdg-output-unstable-v1-client-protocol.h"
|
||||
#include "wayland-xdg-activation-v1-client-protocol.h"
|
||||
#include "wayland-fractional-scale-v1-client-protocol.h"
|
||||
#include "wayland-content-type-v1-client-protocol.h"
|
||||
|
||||
#include "scale.h"
|
||||
|
||||
@@ -83,13 +85,6 @@ struct SurfaceOutput
|
||||
struct wl_list link;
|
||||
};
|
||||
|
||||
enum EGLSwapWithDamageState {
|
||||
SWAP_WITH_DAMAGE_UNKNOWN,
|
||||
SWAP_WITH_DAMAGE_UNSUPPORTED,
|
||||
SWAP_WITH_DAMAGE_KHR,
|
||||
SWAP_WITH_DAMAGE_EXT,
|
||||
};
|
||||
|
||||
struct xkb_context;
|
||||
struct xkb_keymap;
|
||||
struct xkb_state;
|
||||
@@ -175,11 +170,16 @@ struct WaylandDSState
|
||||
|
||||
struct wp_viewporter * viewporter;
|
||||
struct wp_viewport * viewport;
|
||||
struct wp_fractional_scale_manager_v1 * fractionalScaleManager;
|
||||
struct wp_fractional_scale_v1 * fractionalScaleInterface;
|
||||
struct zxdg_output_manager_v1 * xdgOutputManager;
|
||||
struct wl_list outputs; // WaylandOutput::link
|
||||
struct wl_list surfaceOutputs; // SurfaceOutput::link
|
||||
bool useFractionalScale;
|
||||
|
||||
struct wp_content_type_manager_v1 * contentTypeManager;
|
||||
struct wp_content_type_v1 * contentType;
|
||||
|
||||
LGEvent * frameEvent;
|
||||
|
||||
struct wl_list poll; // WaylandPoll::link
|
||||
|
||||
@@ -31,8 +31,25 @@
|
||||
|
||||
// Surface-handling listeners.
|
||||
|
||||
static void setScale(struct WaylandScale newScale)
|
||||
{
|
||||
wlWm.scale = newScale;
|
||||
wlWm.fractionalScale = waylandScaleIsFractional(newScale);
|
||||
wlWm.needsResize = true;
|
||||
|
||||
if (wlWm.desktop->configured())
|
||||
{
|
||||
waylandCursorScaleChange();
|
||||
app_invalidateWindow(true);
|
||||
waylandStopWaitFrame();
|
||||
}
|
||||
}
|
||||
|
||||
void waylandWindowUpdateScale(void)
|
||||
{
|
||||
if (wlWm.fractionalScaleInterface)
|
||||
return;
|
||||
|
||||
struct WaylandScale maxScale = waylandScaleFromInt(0);
|
||||
struct SurfaceOutput * node;
|
||||
|
||||
@@ -44,14 +61,7 @@ void waylandWindowUpdateScale(void)
|
||||
}
|
||||
|
||||
if (waylandScaleValid(maxScale))
|
||||
{
|
||||
wlWm.scale = maxScale;
|
||||
wlWm.fractionalScale = waylandScaleIsFractional(maxScale);
|
||||
wlWm.needsResize = true;
|
||||
waylandCursorScaleChange();
|
||||
app_invalidateWindow(true);
|
||||
waylandStopWaitFrame();
|
||||
}
|
||||
setScale(maxScale);
|
||||
}
|
||||
|
||||
static void wlSurfaceEnterHandler(void * data, struct wl_surface * surface, struct wl_output * output)
|
||||
@@ -85,6 +95,16 @@ static const struct wl_surface_listener wlSurfaceListener = {
|
||||
.leave = wlSurfaceLeaveHandler,
|
||||
};
|
||||
|
||||
static void fractionalScalePreferredScale(void * data,
|
||||
struct wp_fractional_scale_v1 * fractionalScale, uint32_t scale)
|
||||
{
|
||||
setScale(waylandScaleFromRatio(scale, 120));
|
||||
}
|
||||
|
||||
static const struct wp_fractional_scale_v1_listener fractionalScaleListener = {
|
||||
.preferred_scale = fractionalScalePreferredScale,
|
||||
};
|
||||
|
||||
bool waylandWindowInit(const char * title, const char * appId, bool fullscreen, bool maximize, bool borderless, bool resizable)
|
||||
{
|
||||
wlWm.scale = waylandScaleFromInt(1);
|
||||
@@ -110,7 +130,22 @@ bool waylandWindowInit(const char * title, const char * appId, bool fullscreen,
|
||||
return false;
|
||||
}
|
||||
|
||||
wl_surface_add_listener(wlWm.surface, &wlSurfaceListener, NULL);
|
||||
if (wlWm.fractionalScaleManager)
|
||||
{
|
||||
wlWm.fractionalScaleInterface = wp_fractional_scale_manager_v1_get_fractional_scale(
|
||||
wlWm.fractionalScaleManager, wlWm.surface);
|
||||
wp_fractional_scale_v1_add_listener(wlWm.fractionalScaleInterface,
|
||||
&fractionalScaleListener, NULL);
|
||||
}
|
||||
else
|
||||
wl_surface_add_listener(wlWm.surface, &wlSurfaceListener, NULL);
|
||||
|
||||
if (wlWm.contentTypeManager)
|
||||
{
|
||||
wlWm.contentType = wp_content_type_manager_v1_get_surface_content_type(
|
||||
wlWm.contentTypeManager, wlWm.surface);
|
||||
wp_content_type_v1_set_content_type(wlWm.contentType, WP_CONTENT_TYPE_V1_TYPE_GAME);
|
||||
}
|
||||
|
||||
if (!wlWm.desktop->shellInit(wlWm.display, wlWm.surface,
|
||||
title, appId, fullscreen, maximize, borderless, resizable))
|
||||
@@ -122,6 +157,10 @@ bool waylandWindowInit(const char * title, const char * appId, bool fullscreen,
|
||||
|
||||
void waylandWindowFree(void)
|
||||
{
|
||||
if (wlWm.fractionalScaleInterface)
|
||||
wp_fractional_scale_v1_destroy(wlWm.fractionalScaleInterface);
|
||||
if (wlWm.contentType)
|
||||
wp_content_type_v1_destroy(wlWm.contentType);
|
||||
wl_surface_destroy(wlWm.surface);
|
||||
lgFreeEvent(wlWm.frameEvent);
|
||||
}
|
||||
|
||||
@@ -221,8 +221,8 @@ void core_updatePositionInfo(void)
|
||||
.type = LG_MSG_WINDOWSIZE,
|
||||
.windowSize =
|
||||
{
|
||||
.width = g_state.windowW,
|
||||
.height = g_state.windowH
|
||||
.width = round(g_state.windowW * g_state.windowScale),
|
||||
.height = round(g_state.windowH * g_state.windowScale)
|
||||
}
|
||||
};
|
||||
lgMessage_post(&msg);
|
||||
|
||||
@@ -1438,6 +1438,7 @@ static int lg_run(void)
|
||||
core_setGrab(true);
|
||||
|
||||
uint32_t udataSize;
|
||||
uint32_t remoteVersion;
|
||||
KVMFR *udata;
|
||||
int waitCount = 0;
|
||||
|
||||
@@ -1462,7 +1463,7 @@ restart:
|
||||
}
|
||||
|
||||
status = lgmpClientSessionInit(g_state.lgmp, &udataSize, (uint8_t **)&udata,
|
||||
NULL);
|
||||
NULL, &remoteVersion);
|
||||
switch(status)
|
||||
{
|
||||
case LGMP_OK:
|
||||
@@ -1480,6 +1481,8 @@ restart:
|
||||
"Please download and install the matching version."
|
||||
);
|
||||
|
||||
DEBUG_INFO("LGMP host:%u client:%u",
|
||||
remoteVersion, LGMP_PROTOCOL_VERSION);
|
||||
DEBUG_INFO("Waiting for you to upgrade the host application");
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,6 @@ feature is disabled when running :ref:`cmake <client_building>`.
|
||||
- ``libxkbcommon-dev``
|
||||
- ``libwayland-bin``
|
||||
- ``libwayland-dev``
|
||||
- ``wayland-protocols``
|
||||
|
||||
- Disable with ``cmake -DENABLE_PIPEWIRE=no ..``
|
||||
|
||||
@@ -146,7 +145,7 @@ You can fetch these dependencies with the following command:
|
||||
apt-get install binutils-dev cmake fonts-dejavu-core libfontconfig-dev \
|
||||
gcc g++ pkg-config libegl-dev libgl-dev libgles-dev libspice-protocol-dev \
|
||||
nettle-dev libx11-dev libxcursor-dev libxi-dev libxinerama-dev \
|
||||
libxpresent-dev libxss-dev libxkbcommon-dev libwayland-dev wayland-protocols \
|
||||
libxpresent-dev libxss-dev libxkbcommon-dev libwayland-dev \
|
||||
libpipewire-0.3-dev libpulse-dev libsamplerate0-dev
|
||||
|
||||
You may omit some dependencies if you disable the feature which requires them
|
||||
|
||||
@@ -987,11 +987,17 @@ static bool d12_enumerateDevices(
|
||||
DEBUG_INFO("Adapter matched, trying: %ls", adapterDesc.Description);
|
||||
}
|
||||
|
||||
for(
|
||||
int n = 0;
|
||||
IDXGIAdapter1_EnumOutputs(*adapter, n, output) != DXGI_ERROR_NOT_FOUND;
|
||||
++n, comRef_release(output))
|
||||
for (int n = 0; ; ++n, comRef_release(output))
|
||||
{
|
||||
HRESULT hr = IDXGIAdapter1_EnumOutputs(*adapter, n, output);
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
if (hr != DXGI_ERROR_NOT_FOUND)
|
||||
DEBUG_WINERROR("Failed to IDXGIAdapter::EnumOutputs", hr);
|
||||
break;
|
||||
}
|
||||
|
||||
IDXGIOutput_GetDesc(*output, &outputDesc);
|
||||
|
||||
if (optOutput)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2026 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
@@ -31,7 +31,8 @@ struct LGPipeMsg
|
||||
{
|
||||
SETCURSORPOS,
|
||||
SETDISPLAYMODE,
|
||||
GPUSTATUS
|
||||
GPUSTATUS,
|
||||
RELOADSETTINGS
|
||||
}
|
||||
type;
|
||||
union
|
||||
|
||||
@@ -71,7 +71,6 @@ reInit:
|
||||
}
|
||||
|
||||
m_swapChain.reset(new CSwapChainProcessor(m_monitor, m_devContext, swapChain, m_dx11Device, m_dx12Device, newFrameEvent));
|
||||
g_pipe.SetGPUStatus(m_dx11Device->IsSoftware());
|
||||
}
|
||||
|
||||
void CIndirectMonitorContext::UnassignSwapChain()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2026 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
@@ -29,7 +29,7 @@ bool CPipeServer::Init()
|
||||
|
||||
m_pipe.Attach(CreateNamedPipeA(
|
||||
LG_PIPE_NAME,
|
||||
PIPE_ACCESS_DUPLEX,
|
||||
PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
|
||||
PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
|
||||
1,
|
||||
1024,
|
||||
@@ -43,6 +43,13 @@ bool CPipeServer::Init()
|
||||
return false;
|
||||
}
|
||||
|
||||
m_signal.Attach(CreateEvent(NULL, TRUE, FALSE, NULL));
|
||||
if (!m_signal.IsValid())
|
||||
{
|
||||
DEBUG_ERROR_HR(GetLastError(), "Failed to create pipe signal event");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_running = true;
|
||||
m_thread.Attach(CreateThread(
|
||||
NULL,
|
||||
@@ -66,10 +73,11 @@ void CPipeServer::_DeInit()
|
||||
{
|
||||
m_running = false;
|
||||
m_connected = false;
|
||||
if (m_signal.IsValid())
|
||||
SetEvent(m_signal.Get());
|
||||
|
||||
if (m_thread.IsValid())
|
||||
{
|
||||
CancelSynchronousIo(m_thread.Get());
|
||||
WaitForSingleObject(m_thread.Get(), INFINITE);
|
||||
m_thread.Close();
|
||||
}
|
||||
@@ -79,6 +87,8 @@ void CPipeServer::_DeInit()
|
||||
FlushFileBuffers(m_pipe.Get());
|
||||
m_pipe.Close();
|
||||
}
|
||||
|
||||
m_signal.Close();
|
||||
}
|
||||
|
||||
void CPipeServer::DeInit()
|
||||
@@ -91,46 +101,131 @@ void CPipeServer::DeInit()
|
||||
void CPipeServer::Thread()
|
||||
{
|
||||
DEBUG_TRACE("Pipe thread started");
|
||||
|
||||
HandleT<EventTraits> ioEvent(CreateEvent(NULL, TRUE, FALSE, NULL));
|
||||
if (!ioEvent.IsValid())
|
||||
{
|
||||
DEBUG_ERROR_HR(GetLastError(), "Can't create event for overlapped I/O!");
|
||||
WaitForSingleObject(m_signal.Get(), 5000);
|
||||
return;
|
||||
}
|
||||
|
||||
while(m_running)
|
||||
{
|
||||
m_connected = false;
|
||||
bool result = ConnectNamedPipe(m_pipe.Get(), NULL);
|
||||
DWORD err = GetLastError();
|
||||
if (!result && err != ERROR_PIPE_CONNECTED)
|
||||
|
||||
OVERLAPPED overlapped = { 0 };
|
||||
overlapped.hEvent = ioEvent.Get();
|
||||
|
||||
if (!ConnectNamedPipe(m_pipe.Get(), &overlapped))
|
||||
{
|
||||
// if graceful shutdown
|
||||
if ((err == ERROR_OPERATION_ABORTED && !m_running) ||
|
||||
err == ERROR_NO_DATA)
|
||||
DWORD dwError = GetLastError();
|
||||
switch (dwError) {
|
||||
case ERROR_PIPE_CONNECTED:
|
||||
break;
|
||||
|
||||
// if timeout
|
||||
if (err == ERROR_SEM_TIMEOUT)
|
||||
continue;
|
||||
|
||||
DEBUG_FATAL_HR(err, "Error connecting to the named pipe");
|
||||
break;
|
||||
case ERROR_IO_PENDING:
|
||||
{
|
||||
HANDLE hWait[] = { ioEvent.Get(), m_signal.Get() };
|
||||
switch (WaitForMultipleObjects(2, hWait, FALSE, INFINITE))
|
||||
{
|
||||
case WAIT_OBJECT_0:
|
||||
break;
|
||||
case WAIT_OBJECT_0 + 1:
|
||||
DEBUG_INFO("Connect interrupted by signal");
|
||||
CancelIo(m_pipe.Get());
|
||||
WaitForSingleObject(ioEvent.Get(), INFINITE);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
DEBUG_ERROR_HR(dwError, "Error connecting to the named pipe");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_TRACE("Client connected");
|
||||
|
||||
m_connected = true;
|
||||
|
||||
for (const auto& msg : m_queue)
|
||||
WriteMsg(msg);
|
||||
m_queue.clear();
|
||||
|
||||
while (m_running && m_connected)
|
||||
{
|
||||
//TODO: Read messages from the client
|
||||
Sleep(1000);
|
||||
LGPipeMsg msg;
|
||||
|
||||
if (!ReadFile(m_pipe.Get(), &msg, sizeof(msg), NULL, &overlapped))
|
||||
{
|
||||
DWORD dwError = GetLastError();
|
||||
if (dwError != ERROR_IO_PENDING)
|
||||
{
|
||||
DEBUG_ERROR_HR(dwError, "ReadFile Failed");
|
||||
break;
|
||||
}
|
||||
|
||||
HANDLE hWait[] = { ioEvent.Get(), m_signal.Get() };
|
||||
switch (WaitForMultipleObjects(2, hWait, FALSE, INFINITE))
|
||||
{
|
||||
case WAIT_OBJECT_0:
|
||||
break;
|
||||
case WAIT_OBJECT_0 + 1:
|
||||
DEBUG_INFO("I/O interrupted by signal");
|
||||
CancelIo(m_pipe.Get());
|
||||
WaitForSingleObject(ioEvent.Get(), INFINITE);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
DWORD bytesRead;
|
||||
GetOverlappedResult(m_pipe.Get(), &overlapped, &bytesRead, TRUE);
|
||||
|
||||
if (bytesRead != sizeof(msg))
|
||||
{
|
||||
DEBUG_ERROR("Corrupted data, expected %lld bytes, read %lld bytes", sizeof msg, bytesRead);
|
||||
break;
|
||||
}
|
||||
|
||||
if (msg.size != sizeof(msg))
|
||||
{
|
||||
DEBUG_ERROR("Corrupted data, expected %lld bytes, actual message size: %lld bytes", sizeof msg, msg.size);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (msg.type)
|
||||
{
|
||||
case LGPipeMsg::RELOADSETTINGS:
|
||||
HandleReloadSettings();
|
||||
break;
|
||||
|
||||
default:
|
||||
DEBUG_ERROR("Unknown message type %d", msg.type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_TRACE("Client disconnected");
|
||||
DisconnectNamedPipe(m_pipe.Get());
|
||||
|
||||
if (m_running)
|
||||
ResetEvent(m_signal.Get());
|
||||
}
|
||||
|
||||
end:
|
||||
m_running = false;
|
||||
m_connected = false;
|
||||
DEBUG_TRACE("Pipe thread shutdown");
|
||||
}
|
||||
|
||||
void CPipeServer::WriteMsg(LGPipeMsg & msg)
|
||||
void CPipeServer::WriteMsg(const LGPipeMsg & msg)
|
||||
{
|
||||
if (!m_connected)
|
||||
{
|
||||
m_queue.push_back(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
DWORD written;
|
||||
if (!WriteFile(m_pipe.Get(), &msg, sizeof(msg), &written, NULL))
|
||||
{
|
||||
@@ -139,6 +234,7 @@ void CPipeServer::WriteMsg(LGPipeMsg & msg)
|
||||
{
|
||||
DEBUG_WARN_HR(err, "Client disconnected, failed to write");
|
||||
m_connected = false;
|
||||
SetEvent(m_signal.Get());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -149,8 +245,14 @@ void CPipeServer::WriteMsg(LGPipeMsg & msg)
|
||||
FlushFileBuffers(m_pipe.Get());
|
||||
}
|
||||
|
||||
void CPipeServer::HandleReloadSettings()
|
||||
{
|
||||
DEBUG_INFO("TODO: reload settings");
|
||||
}
|
||||
|
||||
void CPipeServer::SetCursorPos(uint32_t x, uint32_t y)
|
||||
{
|
||||
// do not send cursor messages if we are not connected or they will end up queued
|
||||
if (!m_connected)
|
||||
return;
|
||||
|
||||
@@ -164,9 +266,6 @@ void CPipeServer::SetCursorPos(uint32_t x, uint32_t y)
|
||||
|
||||
void CPipeServer::SetDisplayMode(uint32_t width, uint32_t height, uint32_t refresh)
|
||||
{
|
||||
if (!m_connected)
|
||||
return;
|
||||
|
||||
LGPipeMsg msg;
|
||||
msg.size = sizeof(msg);
|
||||
msg.type = LGPipeMsg::SETDISPLAYMODE;
|
||||
@@ -178,9 +277,6 @@ void CPipeServer::SetDisplayMode(uint32_t width, uint32_t height, uint32_t refre
|
||||
|
||||
void CPipeServer::SetGPUStatus(bool software)
|
||||
{
|
||||
if (!m_connected)
|
||||
return;
|
||||
|
||||
LGPipeMsg msg;
|
||||
msg.size = sizeof(msg);
|
||||
msg.type = LGPipeMsg::GPUSTATUS;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2026 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <wdf.h>
|
||||
#include <stdint.h>
|
||||
#include <wrl.h>
|
||||
#include <vector>
|
||||
|
||||
#include "PipeMsg.h"
|
||||
|
||||
@@ -34,8 +35,10 @@ using namespace Microsoft::WRL::Wrappers::HandleTraits;
|
||||
class CPipeServer
|
||||
{
|
||||
private:
|
||||
HandleT<HANDLENullTraits> m_pipe;
|
||||
HandleT<HANDLETraits> m_pipe;
|
||||
HandleT<HANDLENullTraits> m_thread;
|
||||
HandleT<EventTraits> m_signal;
|
||||
std::vector<LGPipeMsg> m_queue;
|
||||
|
||||
bool m_running = false;
|
||||
bool m_connected = false;
|
||||
@@ -45,7 +48,9 @@ class CPipeServer
|
||||
static DWORD WINAPI _pipeThread(LPVOID lpParam) { ((CPipeServer*)lpParam)->Thread(); return 0; }
|
||||
void Thread();
|
||||
|
||||
void WriteMsg(LGPipeMsg & msg);
|
||||
void WriteMsg(const LGPipeMsg & msg);
|
||||
|
||||
void HandleReloadSettings();
|
||||
|
||||
public:
|
||||
~CPipeServer() { DeInit(); }
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <avrt.h>
|
||||
#include "CDebug.h"
|
||||
#include "CPipeServer.h"
|
||||
|
||||
CSwapChainProcessor::CSwapChainProcessor(IDDCX_MONITOR monitor, CIndirectDeviceContext* devContext, IDDCX_SWAPCHAIN hSwapChain,
|
||||
std::shared_ptr<CD3D11Device> dx11Device, std::shared_ptr<CD3D12Device> dx12Device, HANDLE newFrameEvent) :
|
||||
@@ -130,6 +131,10 @@ void CSwapChainProcessor::SwapChainThreadCore()
|
||||
m_lastShapeId = 0;
|
||||
m_thread[1].Attach(CreateThread(nullptr, 0, _CursorThread, this, 0, nullptr));
|
||||
|
||||
// postpone sending this to ensure we dont spam messages if we end up in a
|
||||
// restart loop while waiting for a valid configuration
|
||||
g_pipe.SetGPUStatus(m_dx11Device->IsSoftware());
|
||||
|
||||
UINT lastFrameNumber = 0;
|
||||
for (;;)
|
||||
{
|
||||
|
||||
@@ -35,7 +35,6 @@ bool CConfigWindow::registerClass()
|
||||
{
|
||||
WNDCLASSEX wx = {};
|
||||
populateWindowClass(wx);
|
||||
wx.hIconSm = wx.hIcon = LoadIcon(hInstance, IDI_APPLICATION);
|
||||
wx.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
|
||||
wx.lpszClassName = L"LookingGlassIddConfig";
|
||||
|
||||
@@ -89,7 +88,7 @@ void CConfigWindow::updateFont()
|
||||
}
|
||||
|
||||
for (HWND child : std::initializer_list<HWND>({
|
||||
*m_version, *m_modeGroup, *m_modeBox, *m_widthLabel, *m_heightLabel, *m_refreshLabel,
|
||||
*m_version, *m_modeGroup, *m_modeBox, *m_widthLabel, *m_heightLabel, *m_refreshLabel, *m_modePreferred,
|
||||
*m_modeWidth, *m_modeHeight, *m_modeRefresh, *m_modeUpdate, *m_modeDelete, *m_modeReset,
|
||||
*m_autosizeGroup, *m_defRefreshLabel, *m_defRefresh, *m_defRefreshHz,
|
||||
*m_prefGroup, *m_prefNoGPU,
|
||||
@@ -97,13 +96,20 @@ void CConfigWindow::updateFont()
|
||||
SendMessage(child, WM_SETFONT, (WPARAM)m_font.Get(), 1);
|
||||
}
|
||||
|
||||
void CConfigWindow::updateModeList()
|
||||
int CConfigWindow::updateModeList(int wanted)
|
||||
{
|
||||
int result = 0;
|
||||
m_modeBox->addItem(L"<add new>", -1);
|
||||
|
||||
auto &modes = *m_modes;
|
||||
for (size_t i = 0; i < modes.size(); ++i)
|
||||
m_modeBox->addItem(modes[i].toString(), i);
|
||||
{
|
||||
int idx = m_modeBox->addItem(modes[i].toString(), i);
|
||||
if (wanted == i)
|
||||
result = idx;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
LRESULT CConfigWindow::handleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
@@ -154,6 +160,7 @@ LRESULT CConfigWindow::onCreate()
|
||||
m_modeWidth.reset(new CEditWidget(WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_LEFT | ES_NUMBER, m_hwnd));
|
||||
m_modeHeight.reset(new CEditWidget(WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_LEFT | ES_NUMBER, m_hwnd));
|
||||
m_modeRefresh.reset(new CEditWidget(WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_LEFT | ES_NUMBER, m_hwnd));
|
||||
m_modePreferred.reset(new CCheckbox(L"prefer", WS_CHILD | WS_VISIBLE, m_hwnd));
|
||||
|
||||
m_modeUpdate.reset(new CButton(L"Save", WS_CHILD | WS_VISIBLE | WS_TABSTOP, m_hwnd));
|
||||
m_modeDelete.reset(new CButton(L"Delete", WS_CHILD | WS_VISIBLE | WS_TABSTOP, m_hwnd));
|
||||
@@ -206,6 +213,7 @@ LRESULT CConfigWindow::onResize(DWORD width, DWORD height)
|
||||
pos.pinBottomLeft(*m_modeWidth, 75, 96, 50, 20);
|
||||
pos.pinBottomLeft(*m_modeHeight, 75, 72, 50, 20);
|
||||
pos.pinBottomLeft(*m_modeRefresh, 75, 48, 50, 20);
|
||||
pos.pinBottomLeft(*m_modePreferred, 130, 96, 70, 20);
|
||||
pos.pinBottomLeft(*m_modeUpdate, 24, 20, 50, 24);
|
||||
pos.pinBottomLeft(*m_modeDelete, 75, 20, 50, 24);
|
||||
pos.pinBottomLeft(*m_modeReset, 126, 20, 50, 24);
|
||||
@@ -238,6 +246,7 @@ void CConfigWindow::onModeListSelectChange()
|
||||
m_modeWidth->setNumericValue(mode.width);
|
||||
m_modeHeight->setNumericValue(mode.height);
|
||||
m_modeRefresh->setNumericValue(mode.refresh);
|
||||
m_modePreferred->setChecked(mode.preferred);
|
||||
}
|
||||
EnableWindow(*m_modeUpdate, TRUE);
|
||||
EnableWindow(*m_modeDelete, index >= 0);
|
||||
@@ -249,6 +258,10 @@ LRESULT CConfigWindow::onCommand(WORD id, WORD code, HWND hwnd)
|
||||
{
|
||||
onModeListSelectChange();
|
||||
}
|
||||
else if (m_modePreferred && hwnd == *m_modePreferred && code == BN_CLICKED && m_modes)
|
||||
{
|
||||
m_modePreferred->setChecked(!m_modePreferred->isChecked());
|
||||
}
|
||||
else if (m_modeUpdate && hwnd == *m_modeUpdate && code == BN_CLICKED && m_modes)
|
||||
{
|
||||
int sel = m_modeBox->getSel();
|
||||
@@ -258,24 +271,28 @@ LRESULT CConfigWindow::onCommand(WORD id, WORD code, HWND hwnd)
|
||||
int index = m_modeBox->getData(sel);
|
||||
auto &mode = index >= 0 ? (*m_modes)[index] : m_modes->emplace_back();
|
||||
|
||||
for (auto &mode : *m_modes)
|
||||
mode.preferred = false;
|
||||
|
||||
try
|
||||
{
|
||||
mode.width = m_modeWidth->getNumericValue();
|
||||
mode.height = m_modeHeight->getNumericValue();
|
||||
mode.refresh = m_modeRefresh->getNumericValue();
|
||||
mode.preferred = m_modePreferred->isChecked();
|
||||
}
|
||||
catch (std::logic_error&)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (index >= 0)
|
||||
m_modeBox->delItem(sel);
|
||||
|
||||
m_modeBox->setSel(m_modeBox->addItem(mode.toString().c_str(), index));
|
||||
m_modeBox->clear();
|
||||
m_modeBox->setSel(updateModeList(index));
|
||||
|
||||
LRESULT result = m_settings.setModes(*m_modes);
|
||||
if (result != ERROR_SUCCESS)
|
||||
if (result == ERROR_SUCCESS)
|
||||
sendSettingChange();
|
||||
else
|
||||
DEBUG_ERROR_HR((HRESULT) result, "Failed to save modes");
|
||||
}
|
||||
else if (m_modeDelete && hwnd == *m_modeDelete && code == BN_CLICKED && m_modes)
|
||||
@@ -288,20 +305,27 @@ LRESULT CConfigWindow::onCommand(WORD id, WORD code, HWND hwnd)
|
||||
m_modeBox->clear();
|
||||
m_modes->erase(m_modes->begin() + index);
|
||||
|
||||
LRESULT result = m_settings.setModes(*m_modes);
|
||||
if (result != ERROR_SUCCESS)
|
||||
DEBUG_ERROR_HR((HRESULT) result, "Failed to save modes");
|
||||
|
||||
updateModeList();
|
||||
onModeListSelectChange();
|
||||
|
||||
LRESULT result = m_settings.setModes(*m_modes);
|
||||
if (result == ERROR_SUCCESS)
|
||||
sendSettingChange();
|
||||
else
|
||||
DEBUG_ERROR_HR((HRESULT) result, "Failed to save modes");
|
||||
}
|
||||
else if (m_modeReset && hwnd == *m_modeReset && code == BN_CLICKED && m_modes)
|
||||
{
|
||||
*m_modes = m_settings.getDefaultModes();
|
||||
m_settings.setModes(*m_modes);
|
||||
m_modeBox->clear();
|
||||
updateModeList();
|
||||
onModeListSelectChange();
|
||||
|
||||
LRESULT result = m_settings.setModes(*m_modes);
|
||||
if (result == ERROR_SUCCESS)
|
||||
sendSettingChange();
|
||||
else
|
||||
DEBUG_ERROR_HR((HRESULT)result, "Failed to save modes");
|
||||
}
|
||||
else if (m_defRefresh && hwnd == *m_defRefresh && code == EN_CHANGE && m_defaultRefresh)
|
||||
{
|
||||
@@ -316,8 +340,11 @@ LRESULT CConfigWindow::onCommand(WORD id, WORD code, HWND hwnd)
|
||||
}
|
||||
|
||||
m_defaultRefresh = value;
|
||||
|
||||
LRESULT result = m_settings.setDefaultRefresh(value);
|
||||
if (result != ERROR_SUCCESS)
|
||||
if (result == ERROR_SUCCESS)
|
||||
sendSettingChange();
|
||||
else
|
||||
DEBUG_ERROR_HR((HRESULT)result, "Failed to default refresh");
|
||||
}
|
||||
else if (m_prefNoGPU && hwnd == *m_prefNoGPU && code == BN_CLICKED && m_noGPU)
|
||||
|
||||
@@ -49,6 +49,7 @@ class CConfigWindow : public CWindow
|
||||
std::unique_ptr<CEditWidget> m_modeWidth;
|
||||
std::unique_ptr<CEditWidget> m_modeHeight;
|
||||
std::unique_ptr<CEditWidget> m_modeRefresh;
|
||||
std::unique_ptr<CCheckbox> m_modePreferred;
|
||||
|
||||
std::unique_ptr<CButton> m_modeUpdate;
|
||||
std::unique_ptr<CButton> m_modeDelete;
|
||||
@@ -63,6 +64,8 @@ class CConfigWindow : public CWindow
|
||||
std::unique_ptr<CCheckbox> m_prefNoGPU;
|
||||
|
||||
std::function<void()> m_onDestroy;
|
||||
std::function<void()> m_onSettingChange;
|
||||
|
||||
double m_scale;
|
||||
Microsoft::WRL::Wrappers::HandleT<FontTraits> m_font;
|
||||
CRegistrySettings m_settings;
|
||||
@@ -72,8 +75,9 @@ class CConfigWindow : public CWindow
|
||||
|
||||
void getMinimumSize(LONG &width, LONG &height);
|
||||
void updateFont();
|
||||
void updateModeList();
|
||||
int updateModeList(int wanted = -1);
|
||||
void onModeListSelectChange();
|
||||
void sendSettingChange() { if (m_onSettingChange) m_onSettingChange(); }
|
||||
|
||||
virtual LRESULT handleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) override;
|
||||
virtual LRESULT onCreate() override;
|
||||
@@ -86,4 +90,5 @@ public:
|
||||
static bool registerClass();
|
||||
|
||||
void onDestroy(std::function<void()> func) { m_onDestroy = std::move(func); }
|
||||
void onSettingChange(std::function<void()> func) { m_onSettingChange = std::move(func); }
|
||||
};
|
||||
|
||||
@@ -20,13 +20,14 @@
|
||||
|
||||
#include "CNotifyWindow.h"
|
||||
#include "CConfigWindow.h"
|
||||
#include "Devices.h"
|
||||
#include "Resources.h"
|
||||
#include <CDebug.h>
|
||||
#include <windowsx.h>
|
||||
#include <strsafe.h>
|
||||
|
||||
#define WM_NOTIFY_ICON (WM_USER)
|
||||
#define WM_NOTIFY_ICON (WM_USER)
|
||||
#define WM_CLEAN_UP_CONFIG (WM_USER+1)
|
||||
#define WM_NO_GPU (WM_USER+2)
|
||||
|
||||
#define ID_MENU_SHOW_LOG 3000
|
||||
#define ID_MENU_SHOW_CONFIG 3001
|
||||
@@ -48,8 +49,8 @@ bool CNotifyWindow::registerClass()
|
||||
return s_atom;
|
||||
}
|
||||
|
||||
CNotifyWindow::CNotifyWindow() : m_iconData({ 0 }), m_menu(CreatePopupMenu()),
|
||||
closeRequested(false)
|
||||
CNotifyWindow::CNotifyWindow() : m_iconData({ 0 }), m_iconRegistered(false),
|
||||
m_menu(CreatePopupMenu()), closeRequested(false)
|
||||
{
|
||||
CreateWindowEx(0, MAKEINTATOM(s_atom), NULL,
|
||||
0, 0, 0, 0, 0, NULL, NULL, hInstance, this);
|
||||
@@ -81,6 +82,10 @@ LRESULT CNotifyWindow::handleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
return 0;
|
||||
|
||||
case WM_NO_GPU:
|
||||
handleGPUNotification((bool)wParam);
|
||||
return 0;
|
||||
|
||||
default:
|
||||
if (s_taskbarCreated && uMsg == s_taskbarCreated)
|
||||
{
|
||||
@@ -136,6 +141,8 @@ LRESULT CNotifyWindow::onNotifyIcon(UINT uEvent, WORD wIconId, int x, int y)
|
||||
m_config->onDestroy([this]() {
|
||||
PostMessage(m_hwnd, WM_CLEAN_UP_CONFIG, 0, 0);
|
||||
});
|
||||
if (m_onSettingChange)
|
||||
m_config->onSettingChange(m_onSettingChange);
|
||||
ShowWindow(*m_config, SW_NORMAL);
|
||||
break;
|
||||
}
|
||||
@@ -148,9 +155,9 @@ void CNotifyWindow::registerIcon()
|
||||
{
|
||||
m_iconData.cbSize = sizeof m_iconData;
|
||||
m_iconData.hWnd = m_hwnd;
|
||||
m_iconData.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
|
||||
m_iconData.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP | NIF_SHOWTIP;
|
||||
m_iconData.uCallbackMessage = WM_NOTIFY_ICON;
|
||||
m_iconData.hIcon = LoadIcon(hInstance, IDI_APPLICATION);
|
||||
m_iconData.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(ID_MAIN_ICON));
|
||||
m_iconData.uVersion = NOTIFYICON_VERSION_4;
|
||||
StringCbCopy(m_iconData.szTip, sizeof m_iconData.szTip, L"Looking Glass (IDD)");
|
||||
|
||||
@@ -160,23 +167,45 @@ void CNotifyWindow::registerIcon()
|
||||
return;
|
||||
}
|
||||
|
||||
m_iconRegistered = true;
|
||||
if (!Shell_NotifyIcon(NIM_SETVERSION, &m_iconData))
|
||||
DEBUG_ERROR_HR(GetLastError(), "Shell_NotifyIcon(NIM_SETVERSION)");
|
||||
|
||||
bool hasGPU;
|
||||
if (!checkGPU(hasGPU))
|
||||
DEBUG_ERROR("Failed to check if the system has a GPU");
|
||||
else if (hasGPU)
|
||||
DEBUG_INFO("GPU identified");
|
||||
else
|
||||
if (m_gpuQueue)
|
||||
{
|
||||
DEBUG_INFO("System has no GPU");
|
||||
noGPUNotification();
|
||||
handleGPUNotification(*m_gpuQueue);
|
||||
m_gpuQueue.reset();
|
||||
}
|
||||
}
|
||||
|
||||
void CNotifyWindow::noGPUNotification()
|
||||
void CNotifyWindow::setGPU(bool hasGPU)
|
||||
{
|
||||
if (m_iconRegistered)
|
||||
PostMessage(m_hwnd, WM_NO_GPU, hasGPU, 0);
|
||||
else
|
||||
m_gpuQueue.emplace(hasGPU);
|
||||
}
|
||||
|
||||
void CNotifyWindow::handleGPUNotification(bool hasGPU)
|
||||
{
|
||||
StringCbCopy(m_iconData.szTip, sizeof m_iconData.szTip, hasGPU ?
|
||||
L"Looking Glass (IDD) with GPU acceleration" :
|
||||
L"Looking Glass (IDD) with software rendering");
|
||||
|
||||
if (hasGPU)
|
||||
m_iconData.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(ID_GPU_ICON));
|
||||
else
|
||||
m_iconData.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(ID_NO_GPU_ICON));
|
||||
|
||||
if (!Shell_NotifyIcon(NIM_MODIFY, &m_iconData))
|
||||
{
|
||||
DEBUG_ERROR_HR(GetLastError(), "Shell_NotifyIcon(NIM_ADD)");
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasGPU)
|
||||
return;
|
||||
|
||||
CRegistrySettings settings;
|
||||
LSTATUS error = settings.open();
|
||||
if (error != ERROR_SUCCESS)
|
||||
@@ -189,7 +218,7 @@ void CNotifyWindow::noGPUNotification()
|
||||
NOTIFYICONDATA nid;
|
||||
memcpy(&nid, &m_iconData, sizeof nid);
|
||||
|
||||
nid.uFlags = NIF_INFO;
|
||||
nid.uFlags = NIF_INFO | NIF_SHOWTIP;
|
||||
nid.dwInfoFlags = NIIF_WARNING;
|
||||
StringCbCopy(nid.szInfoTitle, sizeof nid.szInfoTitle, L"No GPU found!");
|
||||
StringCbCopy(nid.szInfo, sizeof nid.szInfo,
|
||||
|
||||
@@ -20,7 +20,9 @@
|
||||
|
||||
#pragma once
|
||||
#include "CWindow.h"
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
class CConfigWindow;
|
||||
|
||||
@@ -30,13 +32,17 @@ class CNotifyWindow : public CWindow
|
||||
static ATOM s_atom;
|
||||
|
||||
NOTIFYICONDATA m_iconData;
|
||||
bool m_iconRegistered;
|
||||
std::optional<bool> m_gpuQueue;
|
||||
HMENU m_menu;
|
||||
bool closeRequested;
|
||||
std::unique_ptr<CConfigWindow> m_config;
|
||||
|
||||
std::function<void()> m_onSettingChange;
|
||||
|
||||
LRESULT onNotifyIcon(UINT uEvent, WORD wIconId, int x, int y);
|
||||
void registerIcon();
|
||||
void noGPUNotification();
|
||||
void handleGPUNotification(bool hasGPU);
|
||||
|
||||
virtual LRESULT handleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) override;
|
||||
virtual LRESULT onCreate() override;
|
||||
@@ -44,11 +50,28 @@ class CNotifyWindow : public CWindow
|
||||
virtual LRESULT onDestroy() override;
|
||||
virtual LRESULT onFinal() override;
|
||||
|
||||
public:
|
||||
CNotifyWindow();
|
||||
~CNotifyWindow() override;
|
||||
|
||||
public:
|
||||
CNotifyWindow(const CNotifyWindow&) = delete;
|
||||
CNotifyWindow& operator=(const CNotifyWindow&) = delete;
|
||||
|
||||
CNotifyWindow(CNotifyWindow&&) = delete;
|
||||
CNotifyWindow& operator=(CNotifyWindow&&) = delete;
|
||||
|
||||
static CNotifyWindow& instance()
|
||||
{
|
||||
static CNotifyWindow window;
|
||||
return window;
|
||||
}
|
||||
|
||||
static bool registerClass();
|
||||
|
||||
void setGPU(bool hasGPU);
|
||||
|
||||
HWND hwndDialog();
|
||||
void close();
|
||||
};
|
||||
|
||||
void onSettingChange(std::function<void()> func) { m_onSettingChange = std::move(func); }
|
||||
};
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "CPipeClient.h"
|
||||
#include "CDebug.h"
|
||||
#include "CNotifyWindow.h"
|
||||
|
||||
#include <setupapi.h>
|
||||
#include <tchar.h>
|
||||
@@ -169,6 +170,17 @@ void CPipeClient::WriteMsg(const LGPipeMsg& msg)
|
||||
FlushFileBuffers(m_pipe.Get());
|
||||
}
|
||||
|
||||
void CPipeClient::ReloadSettings()
|
||||
{
|
||||
if (!m_connected)
|
||||
return;
|
||||
|
||||
LGPipeMsg msg;
|
||||
msg.size = sizeof(msg);
|
||||
msg.type = LGPipeMsg::RELOADSETTINGS;
|
||||
WriteMsg(msg);
|
||||
}
|
||||
|
||||
void CPipeClient::Thread()
|
||||
{
|
||||
DEBUG_INFO("Pipe thread started");
|
||||
@@ -307,5 +319,5 @@ void CPipeClient::HandleSetDisplayMode(const LGPipeMsg& msg)
|
||||
|
||||
void CPipeClient::HandleGPUStatus(const LGPipeMsg& msg)
|
||||
{
|
||||
// TODO: implement me
|
||||
CNotifyWindow::instance().setGPU(!msg.gpuStatus.software);
|
||||
}
|
||||
|
||||
@@ -59,6 +59,8 @@ public:
|
||||
bool Init();
|
||||
void DeInit();
|
||||
bool IsRunning() { return m_running; }
|
||||
|
||||
void ReloadSettings();
|
||||
};
|
||||
|
||||
extern CPipeClient g_pipe;
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <windowsx.h>
|
||||
#include <strsafe.h>
|
||||
#include <CDebug.h>
|
||||
#include "Resources.h"
|
||||
|
||||
HINSTANCE CWindow::hInstance = (HINSTANCE)GetModuleHandle(NULL);
|
||||
|
||||
@@ -30,8 +31,8 @@ void CWindow::populateWindowClass(WNDCLASSEX &wx)
|
||||
wx.cbSize = sizeof(WNDCLASSEX);
|
||||
wx.lpfnWndProc = wndProc;
|
||||
wx.hInstance = hInstance;
|
||||
wx.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
||||
wx.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
|
||||
wx.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(ID_MAIN_ICON));
|
||||
wx.hIconSm = wx.hIcon;
|
||||
wx.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wx.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
||||
}
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2026 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 "Devices.h"
|
||||
#include <windows.h>
|
||||
#include <devguid.h>
|
||||
#include <setupapi.h>
|
||||
#include <CDebug.h>
|
||||
|
||||
inline static bool wprefix(const wchar_t *pre, const wchar_t *str)
|
||||
{
|
||||
return wcsncmp(pre, str, wcslen(pre)) == 0;
|
||||
}
|
||||
|
||||
bool checkGPU(bool &found)
|
||||
{
|
||||
found = false;
|
||||
|
||||
HDEVINFO hDevInfo = SetupDiGetClassDevsW(&GUID_DEVCLASS_DISPLAY, NULL, NULL, DIGCF_PRESENT);
|
||||
if (hDevInfo == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
DEBUG_WARN_HR(GetLastError(), L"SetupDiGetClassDevsW");
|
||||
return false;
|
||||
}
|
||||
|
||||
SP_DEVINFO_DATA devInfo = { 0 };
|
||||
devInfo.cbSize = sizeof devInfo;
|
||||
|
||||
for (DWORD dwIndex = 0; SetupDiEnumDeviceInfo(hDevInfo, dwIndex, &devInfo); ++dwIndex)
|
||||
{
|
||||
DWORD dwSizeRequired;
|
||||
DWORD dwPropertyType;
|
||||
SetupDiGetDeviceRegistryPropertyW(hDevInfo, &devInfo, SPDRP_HARDWAREID, &dwPropertyType, NULL, 0, &dwSizeRequired);
|
||||
|
||||
DWORD dwLastError = GetLastError();
|
||||
if (dwLastError == ERROR_INVALID_DATA)
|
||||
continue;
|
||||
else if (dwLastError != ERROR_INSUFFICIENT_BUFFER)
|
||||
{
|
||||
DEBUG_WARN_HR(GetLastError(), L"SetupDiGetDeviceRegistryPropertyW(SPDRP_HARDWAREID) size calculation");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (dwPropertyType != REG_MULTI_SZ)
|
||||
{
|
||||
DEBUG_WARN(L"SetupDiGetDeviceRegistryPropertyW(SPDRP_HARDWAREID) returned wrong type");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
LPWSTR lpBuffer = (LPWSTR)malloc(dwSizeRequired);
|
||||
if (!lpBuffer)
|
||||
{
|
||||
DEBUG_WARN(L"failed to allocate memory for SetupDiGetDeviceRegistryPropertyW(SPDRP_HARDWAREID)");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!SetupDiGetDeviceRegistryPropertyW(hDevInfo, &devInfo, SPDRP_HARDWAREID, &dwPropertyType, (PBYTE)lpBuffer, dwSizeRequired, NULL))
|
||||
{
|
||||
DEBUG_WARN_HR(GetLastError(), L"SetupDiGetDeviceRegistryPropertyW(SPDRP_HARDWAREID) for real");
|
||||
free(lpBuffer);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
for (LPWSTR lpHwId = lpBuffer; *lpHwId; lpHwId += wcslen(lpBuffer) + 1)
|
||||
{
|
||||
if (
|
||||
wprefix(L"PCI\\VEN_10DE&", lpHwId) || // Nvidia
|
||||
wprefix(L"PCI\\VEN_1002&", lpHwId) || // AMD
|
||||
wprefix(L"PCI\\VEN_8086&", lpHwId) // Intel
|
||||
)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
free(lpBuffer);
|
||||
|
||||
if (found)
|
||||
break;
|
||||
}
|
||||
|
||||
SetupDiDestroyDeviceInfoList(hDevInfo);
|
||||
return true;
|
||||
|
||||
fail:
|
||||
SetupDiDestroyDeviceInfoList(hDevInfo);
|
||||
return false;
|
||||
}
|
||||
9
idd/LGIddHelper/HighDPI.manifest
Normal file
9
idd/LGIddHelper/HighDPI.manifest
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
|
||||
<asmv3:application>
|
||||
<asmv3:windowsSettings>
|
||||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware>
|
||||
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
|
||||
</asmv3:windowsSettings>
|
||||
</asmv3:application>
|
||||
</assembly>
|
||||
@@ -91,7 +91,8 @@ copy /Y "$(ProjectDir)VERSION" "$(SolutionDir)$(Platform)\$(Configuration)\LGIdd
|
||||
</PostBuildEvent>
|
||||
<Manifest />
|
||||
<Manifest>
|
||||
<EnableDpiAwareness>PerMonitorHighDPIAware</EnableDpiAwareness>
|
||||
<EnableDpiAwareness>false</EnableDpiAwareness>
|
||||
<InputResourceManifests>$(ProjectDir)HighDPI.manifest</InputResourceManifests>
|
||||
</Manifest>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
@@ -118,7 +119,8 @@ copy /Y "$(ProjectDir)VERSION" "$(SolutionDir)$(Platform)\$(Configuration)\LGIdd
|
||||
</PostBuildEvent>
|
||||
<Manifest />
|
||||
<Manifest>
|
||||
<EnableDpiAwareness>PerMonitorHighDPIAware</EnableDpiAwareness>
|
||||
<EnableDpiAwareness>false</EnableDpiAwareness>
|
||||
<InputResourceManifests>$(ProjectDir)HighDPI.manifest</InputResourceManifests>
|
||||
</Manifest>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
@@ -144,7 +146,8 @@ copy /Y "$(ProjectDir)VERSION" "$(SolutionDir)$(Platform)\$(Configuration)\LGIdd
|
||||
</PostBuildEvent>
|
||||
<Manifest />
|
||||
<Manifest>
|
||||
<EnableDpiAwareness>PerMonitorHighDPIAware</EnableDpiAwareness>
|
||||
<EnableDpiAwareness>false</EnableDpiAwareness>
|
||||
<InputResourceManifests>$(ProjectDir)HighDPI.manifest</InputResourceManifests>
|
||||
</Manifest>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
@@ -174,7 +177,8 @@ copy /Y "$(ProjectDir)VERSION" "$(SolutionDir)$(Platform)\$(Configuration)\LGIdd
|
||||
</PostBuildEvent>
|
||||
<Manifest />
|
||||
<Manifest>
|
||||
<EnableDpiAwareness>PerMonitorHighDPIAware</EnableDpiAwareness>
|
||||
<EnableDpiAwareness>false</EnableDpiAwareness>
|
||||
<InputResourceManifests>$(ProjectDir)HighDPI.manifest</InputResourceManifests>
|
||||
</Manifest>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
@@ -191,7 +195,6 @@ copy /Y "$(ProjectDir)VERSION" "$(SolutionDir)$(Platform)\$(Configuration)\LGIdd
|
||||
<ClCompile Include="CStaticWidget.cpp" />
|
||||
<ClCompile Include="CWidget.cpp" />
|
||||
<ClCompile Include="CWindow.cpp" />
|
||||
<ClCompile Include="Devices.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="UIHelpers.cpp" />
|
||||
</ItemGroup>
|
||||
@@ -208,7 +211,7 @@ copy /Y "$(ProjectDir)VERSION" "$(SolutionDir)$(Platform)\$(Configuration)\LGIdd
|
||||
<ClInclude Include="CRegistrySettings.h" />
|
||||
<ClInclude Include="CStaticWidget.h" />
|
||||
<ClInclude Include="CWidget.h" />
|
||||
<ClInclude Include="Devices.h" />
|
||||
<ClInclude Include="Resources.h" />
|
||||
<ClInclude Include="UIHelpers.h" />
|
||||
<ClInclude Include="CWindow.h" />
|
||||
</ItemGroup>
|
||||
@@ -218,6 +221,9 @@ copy /Y "$(ProjectDir)VERSION" "$(SolutionDir)$(Platform)\$(Configuration)\LGIdd
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="resource.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Manifest Include="HighDPI.manifest" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets" />
|
||||
<Target Name="GenerateVersionInfo" BeforeTargets="ClCompile">
|
||||
|
||||
@@ -22,14 +22,12 @@
|
||||
<ClCompile Include="CPipeClient.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(SolutionDir)LGCommon\*.cpp" />
|
||||
<ClCompile Include="CWindow.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CNotifyWindow.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(SolutionDir)LGCommon\*.cpp" />
|
||||
<ClCompile Include="CConfigWindow.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@@ -39,7 +37,6 @@
|
||||
<ClCompile Include="CWidget.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(SolutionDir)LGCommon\*.cpp" />
|
||||
<ClCompile Include="CRegistrySettings.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@@ -49,18 +46,16 @@
|
||||
<ClCompile Include="UIHelpers.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(SolutionDir)LGCommon\*.cpp" />
|
||||
<ClCompile Include="CGroupBox.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(SolutionDir)LGCommon\*.cpp" />
|
||||
<ClCompile Include="CButton.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CEditWidget.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Devices.cpp">
|
||||
<ClCompile Include="CCheckbox.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
@@ -69,16 +64,12 @@
|
||||
<ClInclude Include="CPipeClient.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<CLInclude Include="$(SolutionDir)LGCommon\*.h" />
|
||||
<CLInclude Include="$(SolutionDir)LGCommon\*.h" />
|
||||
<ClInclude Include="CWindow.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CNotifyWindow.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<CLInclude Include="$(SolutionDir)LGCommon\*.h" />
|
||||
<CLInclude Include="$(SolutionDir)LGCommon\*.h" />
|
||||
<ClInclude Include="CConfigWindow.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
@@ -91,29 +82,25 @@
|
||||
<ClInclude Include="UIHelpers.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<CLInclude Include="$(SolutionDir)LGCommon\*.h" />
|
||||
<CLInclude Include="$(SolutionDir)LGCommon\*.h" />
|
||||
<ClInclude Include="CRegistrySettings.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CListBox.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<CLInclude Include="$(SolutionDir)LGCommon\*.h" />
|
||||
<CLInclude Include="$(SolutionDir)LGCommon\*.h" />
|
||||
<ClInclude Include="CGroupBox.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<CLInclude Include="$(SolutionDir)LGCommon\*.h" />
|
||||
<CLInclude Include="$(SolutionDir)LGCommon\*.h" />
|
||||
<CLInclude Include="$(SolutionDir)LGCommon\*.h" />
|
||||
<ClInclude Include="CButton.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CEditWidget.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Devices.h">
|
||||
<ClInclude Include="CCheckbox.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Resources.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
@@ -125,4 +112,7 @@
|
||||
<Filter>Resource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Manifest Include="HighDPI.manifest" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -20,4 +20,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
bool checkGPU(bool &found);
|
||||
#define ID_MAIN_ICON 1
|
||||
#define ID_GPU_ICON 2
|
||||
#define ID_NO_GPU_ICON 3
|
||||
@@ -113,10 +113,16 @@ int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
CNotifyWindow& window = CNotifyWindow::instance();
|
||||
|
||||
// the pipe must be initialized after the CNotifyWindow
|
||||
// has been created to avoid a potential race
|
||||
if (!g_pipe.Init())
|
||||
return EXIT_FAILURE;
|
||||
|
||||
CNotifyWindow window;
|
||||
window.onSettingChange([]() {
|
||||
g_pipe.ReloadSettings();
|
||||
});
|
||||
|
||||
HANDLE hWait;
|
||||
if (!RegisterWaitForSingleObject(&hWait, hParent.Get(), DestroyNotifyWindow, &window, INFINITE, WT_EXECUTEONLYONCE))
|
||||
|
||||
@@ -22,8 +22,11 @@
|
||||
#include "winuser.h"
|
||||
#include "winver.h"
|
||||
#include "VersionInfo.h"
|
||||
#include "Resources.h"
|
||||
|
||||
IDI_APPLICATION ICON "../../resources/icon.ico"
|
||||
ID_MAIN_ICON ICON "../../resources/icon.ico"
|
||||
ID_GPU_ICON ICON "../../resources/icon-gpu.ico"
|
||||
ID_NO_GPU_ICON ICON "../../resources/icon-nogpu.ico"
|
||||
|
||||
#define STRINGIFY2(s) L#s
|
||||
#define STRINGIFY(s) STRINGIFY2(s)
|
||||
|
||||
24
obs/lg.c
24
obs/lg.c
@@ -490,15 +490,31 @@ static void lgUpdate(void * data, obs_data_t * settings)
|
||||
uint32_t udataSize;
|
||||
KVMFR * udata;
|
||||
|
||||
if (lgmpClientInit(this->shmDev.mem, this->shmDev.size, &this->lgmp)
|
||||
!= LGMP_OK)
|
||||
LGMP_STATUS status;
|
||||
if ((status = lgmpClientInit(this->shmDev.mem, this->shmDev.size,
|
||||
&this->lgmp)) != LGMP_OK)
|
||||
{
|
||||
printf("lgmpClientInit: %s\n", lgmpStatusString(status));
|
||||
return;
|
||||
}
|
||||
|
||||
usleep(200000);
|
||||
|
||||
if (lgmpClientSessionInit(this->lgmp, &udataSize, (uint8_t **)&udata, NULL)
|
||||
!= LGMP_OK)
|
||||
uint32_t remoteVersion;
|
||||
if ((status = lgmpClientSessionInit(this->lgmp, &udataSize,
|
||||
(uint8_t **)&udata, NULL, &remoteVersion)) != LGMP_OK)
|
||||
{
|
||||
printf("lgmpClientSessionInit: %s", lgmpStatusString(status));
|
||||
if (status == LGMP_ERR_INVALID_VERSION)
|
||||
{
|
||||
printf("The host application is not compatible with this client\n");
|
||||
printf("Expected LGMP version %u but got %u\n",
|
||||
LGMP_PROTOCOL_VERSION, remoteVersion);
|
||||
printf("This is not a Looking Glass error, do not report this");
|
||||
}
|
||||
printf("\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (udataSize < sizeof(KVMFR) ||
|
||||
memcmp(udata->magic, KVMFR_MAGIC, sizeof(udata->magic)) != 0 ||
|
||||
|
||||
Submodule repos/LGMP updated: cee2933221...149c731050
Submodule repos/wayland-protocols updated: d324986823...02e63e74a8
BIN
resources/icon-gpu.ico
Normal file
BIN
resources/icon-gpu.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 88 KiB |
BIN
resources/icon-nogpu.ico
Normal file
BIN
resources/icon-nogpu.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 88 KiB |
Reference in New Issue
Block a user