mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-06-13 10:14:28 +00:00
Compare commits
1 Commits
master
...
idd-prefer
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04607d6139 |
@@ -60,12 +60,6 @@ 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,9 +46,6 @@ 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);
|
||||
@@ -71,9 +68,6 @@ 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 / 2) / scale.den);
|
||||
return (int)(((int64_t)value * scale.num) / scale.den);
|
||||
}
|
||||
|
||||
static inline double waylandScaleToDouble(struct WaylandScale scale)
|
||||
|
||||
@@ -47,8 +47,6 @@
|
||||
#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"
|
||||
|
||||
@@ -85,6 +83,13 @@ 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;
|
||||
@@ -170,16 +175,11 @@ 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,21 +31,8 @@
|
||||
|
||||
// Surface-handling listeners.
|
||||
|
||||
static void setScale(struct WaylandScale newScale)
|
||||
{
|
||||
wlWm.scale = newScale;
|
||||
wlWm.fractionalScale = waylandScaleIsFractional(newScale);
|
||||
wlWm.needsResize = true;
|
||||
waylandCursorScaleChange();
|
||||
app_invalidateWindow(true);
|
||||
waylandStopWaitFrame();
|
||||
}
|
||||
|
||||
void waylandWindowUpdateScale(void)
|
||||
{
|
||||
if (wlWm.fractionalScaleInterface)
|
||||
return;
|
||||
|
||||
struct WaylandScale maxScale = waylandScaleFromInt(0);
|
||||
struct SurfaceOutput * node;
|
||||
|
||||
@@ -57,7 +44,14 @@ void waylandWindowUpdateScale(void)
|
||||
}
|
||||
|
||||
if (waylandScaleValid(maxScale))
|
||||
setScale(maxScale);
|
||||
{
|
||||
wlWm.scale = maxScale;
|
||||
wlWm.fractionalScale = waylandScaleIsFractional(maxScale);
|
||||
wlWm.needsResize = true;
|
||||
waylandCursorScaleChange();
|
||||
app_invalidateWindow(true);
|
||||
waylandStopWaitFrame();
|
||||
}
|
||||
}
|
||||
|
||||
static void wlSurfaceEnterHandler(void * data, struct wl_surface * surface, struct wl_output * output)
|
||||
@@ -91,16 +85,6 @@ 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);
|
||||
@@ -126,22 +110,7 @@ bool waylandWindowInit(const char * title, const char * appId, bool fullscreen,
|
||||
return false;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
wl_surface_add_listener(wlWm.surface, &wlSurfaceListener, NULL);
|
||||
|
||||
if (!wlWm.desktop->shellInit(wlWm.display, wlWm.surface,
|
||||
title, appId, fullscreen, maximize, borderless, resizable))
|
||||
@@ -153,10 +122,6 @@ 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 = round(g_state.windowW * g_state.windowScale),
|
||||
.height = round(g_state.windowH * g_state.windowScale)
|
||||
.width = g_state.windowW,
|
||||
.height = g_state.windowH
|
||||
}
|
||||
};
|
||||
lgMessage_post(&msg);
|
||||
|
||||
@@ -105,6 +105,7 @@ feature is disabled when running :ref:`cmake <client_building>`.
|
||||
- ``libxkbcommon-dev``
|
||||
- ``libwayland-bin``
|
||||
- ``libwayland-dev``
|
||||
- ``wayland-protocols``
|
||||
|
||||
- Disable with ``cmake -DENABLE_PIPEWIRE=no ..``
|
||||
|
||||
@@ -145,7 +146,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 \
|
||||
libxpresent-dev libxss-dev libxkbcommon-dev libwayland-dev wayland-protocols \
|
||||
libpipewire-0.3-dev libpulse-dev libsamplerate0-dev
|
||||
|
||||
You may omit some dependencies if you disable the feature which requires them
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2026 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
@@ -31,8 +31,7 @@ struct LGPipeMsg
|
||||
{
|
||||
SETCURSORPOS,
|
||||
SETDISPLAYMODE,
|
||||
GPUSTATUS,
|
||||
RELOADSETTINGS
|
||||
GPUSTATUS
|
||||
}
|
||||
type;
|
||||
union
|
||||
|
||||
@@ -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 | FILE_FLAG_OVERLAPPED,
|
||||
PIPE_ACCESS_DUPLEX,
|
||||
PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
|
||||
1,
|
||||
1024,
|
||||
@@ -43,13 +43,6 @@ 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,
|
||||
@@ -73,11 +66,10 @@ 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();
|
||||
}
|
||||
@@ -87,8 +79,6 @@ void CPipeServer::_DeInit()
|
||||
FlushFileBuffers(m_pipe.Get());
|
||||
m_pipe.Close();
|
||||
}
|
||||
|
||||
m_signal.Close();
|
||||
}
|
||||
|
||||
void CPipeServer::DeInit()
|
||||
@@ -101,47 +91,24 @@ 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;
|
||||
|
||||
OVERLAPPED overlapped = { 0 };
|
||||
overlapped.hEvent = ioEvent.Get();
|
||||
|
||||
if (!ConnectNamedPipe(m_pipe.Get(), &overlapped))
|
||||
bool result = ConnectNamedPipe(m_pipe.Get(), NULL);
|
||||
DWORD err = GetLastError();
|
||||
if (!result && err != ERROR_PIPE_CONNECTED)
|
||||
{
|
||||
DWORD dwError = GetLastError();
|
||||
switch (dwError) {
|
||||
case ERROR_PIPE_CONNECTED:
|
||||
// if graceful shutdown
|
||||
if ((err == ERROR_OPERATION_ABORTED && !m_running) ||
|
||||
err == ERROR_NO_DATA)
|
||||
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;
|
||||
}
|
||||
|
||||
// if timeout
|
||||
if (err == ERROR_SEM_TIMEOUT)
|
||||
continue;
|
||||
|
||||
DEBUG_FATAL_HR(err, "Error connecting to the named pipe");
|
||||
break;
|
||||
}
|
||||
|
||||
DEBUG_TRACE("Client connected");
|
||||
@@ -154,65 +121,14 @@ void CPipeServer::Thread()
|
||||
|
||||
while (m_running && m_connected)
|
||||
{
|
||||
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;
|
||||
}
|
||||
//TODO: Read messages from the client
|
||||
Sleep(1000);
|
||||
}
|
||||
|
||||
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");
|
||||
@@ -234,7 +150,6 @@ void CPipeServer::WriteMsg(const LGPipeMsg & msg)
|
||||
{
|
||||
DEBUG_WARN_HR(err, "Client disconnected, failed to write");
|
||||
m_connected = false;
|
||||
SetEvent(m_signal.Get());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -245,11 +160,6 @@ void CPipeServer::WriteMsg(const 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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2026 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
@@ -35,9 +35,8 @@ using namespace Microsoft::WRL::Wrappers::HandleTraits;
|
||||
class CPipeServer
|
||||
{
|
||||
private:
|
||||
HandleT<HANDLETraits> m_pipe;
|
||||
HandleT<HANDLENullTraits> m_pipe;
|
||||
HandleT<HANDLENullTraits> m_thread;
|
||||
HandleT<EventTraits> m_signal;
|
||||
std::vector<LGPipeMsg> m_queue;
|
||||
|
||||
bool m_running = false;
|
||||
@@ -50,8 +49,6 @@ class CPipeServer
|
||||
|
||||
void WriteMsg(const LGPipeMsg & msg);
|
||||
|
||||
void HandleReloadSettings();
|
||||
|
||||
public:
|
||||
~CPipeServer() { DeInit(); }
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ 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";
|
||||
|
||||
@@ -290,9 +291,7 @@ LRESULT CConfigWindow::onCommand(WORD id, WORD code, HWND hwnd)
|
||||
m_modeBox->setSel(updateModeList(index));
|
||||
|
||||
LRESULT result = m_settings.setModes(*m_modes);
|
||||
if (result == ERROR_SUCCESS)
|
||||
sendSettingChange();
|
||||
else
|
||||
if (result != ERROR_SUCCESS)
|
||||
DEBUG_ERROR_HR((HRESULT) result, "Failed to save modes");
|
||||
}
|
||||
else if (m_modeDelete && hwnd == *m_modeDelete && code == BN_CLICKED && m_modes)
|
||||
@@ -305,27 +304,20 @@ 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)
|
||||
{
|
||||
@@ -340,11 +332,8 @@ LRESULT CConfigWindow::onCommand(WORD id, WORD code, HWND hwnd)
|
||||
}
|
||||
|
||||
m_defaultRefresh = value;
|
||||
|
||||
LRESULT result = m_settings.setDefaultRefresh(value);
|
||||
if (result == ERROR_SUCCESS)
|
||||
sendSettingChange();
|
||||
else
|
||||
if (result != ERROR_SUCCESS)
|
||||
DEBUG_ERROR_HR((HRESULT)result, "Failed to default refresh");
|
||||
}
|
||||
else if (m_prefNoGPU && hwnd == *m_prefNoGPU && code == BN_CLICKED && m_noGPU)
|
||||
|
||||
@@ -64,8 +64,6 @@ 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;
|
||||
@@ -77,7 +75,6 @@ class CConfigWindow : public CWindow
|
||||
void updateFont();
|
||||
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;
|
||||
@@ -90,5 +87,4 @@ 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,7 +20,6 @@
|
||||
|
||||
#include "CNotifyWindow.h"
|
||||
#include "CConfigWindow.h"
|
||||
#include "Resources.h"
|
||||
#include <CDebug.h>
|
||||
#include <windowsx.h>
|
||||
#include <strsafe.h>
|
||||
@@ -49,8 +48,8 @@ bool CNotifyWindow::registerClass()
|
||||
return s_atom;
|
||||
}
|
||||
|
||||
CNotifyWindow::CNotifyWindow() : m_iconData({ 0 }), m_iconRegistered(false),
|
||||
m_menu(CreatePopupMenu()), closeRequested(false)
|
||||
CNotifyWindow::CNotifyWindow() : m_iconData({ 0 }), m_menu(CreatePopupMenu()),
|
||||
closeRequested(false)
|
||||
{
|
||||
CreateWindowEx(0, MAKEINTATOM(s_atom), NULL,
|
||||
0, 0, 0, 0, 0, NULL, NULL, hInstance, this);
|
||||
@@ -83,7 +82,7 @@ LRESULT CNotifyWindow::handleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
return 0;
|
||||
|
||||
case WM_NO_GPU:
|
||||
handleGPUNotification((bool)wParam);
|
||||
handleNoGPUNotification();
|
||||
return 0;
|
||||
|
||||
default:
|
||||
@@ -141,8 +140,6 @@ 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;
|
||||
}
|
||||
@@ -155,9 +152,9 @@ void CNotifyWindow::registerIcon()
|
||||
{
|
||||
m_iconData.cbSize = sizeof m_iconData;
|
||||
m_iconData.hWnd = m_hwnd;
|
||||
m_iconData.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP | NIF_SHOWTIP;
|
||||
m_iconData.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
|
||||
m_iconData.uCallbackMessage = WM_NOTIFY_ICON;
|
||||
m_iconData.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(ID_MAIN_ICON));
|
||||
m_iconData.hIcon = LoadIcon(hInstance, IDI_APPLICATION);
|
||||
m_iconData.uVersion = NOTIFYICON_VERSION_4;
|
||||
StringCbCopy(m_iconData.szTip, sizeof m_iconData.szTip, L"Looking Glass (IDD)");
|
||||
|
||||
@@ -167,45 +164,17 @@ void CNotifyWindow::registerIcon()
|
||||
return;
|
||||
}
|
||||
|
||||
m_iconRegistered = true;
|
||||
if (!Shell_NotifyIcon(NIM_SETVERSION, &m_iconData))
|
||||
DEBUG_ERROR_HR(GetLastError(), "Shell_NotifyIcon(NIM_SETVERSION)");
|
||||
|
||||
if (m_gpuQueue)
|
||||
{
|
||||
handleGPUNotification(*m_gpuQueue);
|
||||
m_gpuQueue.reset();
|
||||
}
|
||||
}
|
||||
|
||||
void CNotifyWindow::setGPU(bool hasGPU)
|
||||
void CNotifyWindow::noGPUNotification()
|
||||
{
|
||||
if (m_iconRegistered)
|
||||
PostMessage(m_hwnd, WM_NO_GPU, hasGPU, 0);
|
||||
else
|
||||
m_gpuQueue.emplace(hasGPU);
|
||||
PostMessage(m_hwnd, WM_NO_GPU, 0, 0);
|
||||
}
|
||||
|
||||
void CNotifyWindow::handleGPUNotification(bool hasGPU)
|
||||
void CNotifyWindow::handleNoGPUNotification()
|
||||
{
|
||||
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)
|
||||
@@ -218,7 +187,7 @@ void CNotifyWindow::handleGPUNotification(bool hasGPU)
|
||||
NOTIFYICONDATA nid;
|
||||
memcpy(&nid, &m_iconData, sizeof nid);
|
||||
|
||||
nid.uFlags = NIF_INFO | NIF_SHOWTIP;
|
||||
nid.uFlags = NIF_INFO;
|
||||
nid.dwInfoFlags = NIIF_WARNING;
|
||||
StringCbCopy(nid.szInfoTitle, sizeof nid.szInfoTitle, L"No GPU found!");
|
||||
StringCbCopy(nid.szInfo, sizeof nid.szInfo,
|
||||
|
||||
@@ -20,9 +20,7 @@
|
||||
|
||||
#pragma once
|
||||
#include "CWindow.h"
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
class CConfigWindow;
|
||||
|
||||
@@ -32,17 +30,13 @@ 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 handleGPUNotification(bool hasGPU);
|
||||
void handleNoGPUNotification();
|
||||
|
||||
virtual LRESULT handleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) override;
|
||||
virtual LRESULT onCreate() override;
|
||||
@@ -68,10 +62,8 @@ public:
|
||||
|
||||
static bool registerClass();
|
||||
|
||||
void setGPU(bool hasGPU);
|
||||
void noGPUNotification();
|
||||
|
||||
HWND hwndDialog();
|
||||
void close();
|
||||
|
||||
void onSettingChange(std::function<void()> func) { m_onSettingChange = std::move(func); }
|
||||
};
|
||||
@@ -170,17 +170,6 @@ 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");
|
||||
@@ -319,5 +308,6 @@ void CPipeClient::HandleSetDisplayMode(const LGPipeMsg& msg)
|
||||
|
||||
void CPipeClient::HandleGPUStatus(const LGPipeMsg& msg)
|
||||
{
|
||||
CNotifyWindow::instance().setGPU(!msg.gpuStatus.software);
|
||||
if (msg.gpuStatus.software)
|
||||
CNotifyWindow::instance().noGPUNotification();
|
||||
}
|
||||
|
||||
@@ -59,8 +59,6 @@ public:
|
||||
bool Init();
|
||||
void DeInit();
|
||||
bool IsRunning() { return m_running; }
|
||||
|
||||
void ReloadSettings();
|
||||
};
|
||||
|
||||
extern CPipeClient g_pipe;
|
||||
@@ -22,7 +22,6 @@
|
||||
#include <windowsx.h>
|
||||
#include <strsafe.h>
|
||||
#include <CDebug.h>
|
||||
#include "Resources.h"
|
||||
|
||||
HINSTANCE CWindow::hInstance = (HINSTANCE)GetModuleHandle(NULL);
|
||||
|
||||
@@ -31,8 +30,8 @@ void CWindow::populateWindowClass(WNDCLASSEX &wx)
|
||||
wx.cbSize = sizeof(WNDCLASSEX);
|
||||
wx.lpfnWndProc = wndProc;
|
||||
wx.hInstance = hInstance;
|
||||
wx.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(ID_MAIN_ICON));
|
||||
wx.hIconSm = wx.hIcon;
|
||||
wx.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
||||
wx.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
|
||||
wx.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wx.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
<?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,8 +91,7 @@ copy /Y "$(ProjectDir)VERSION" "$(SolutionDir)$(Platform)\$(Configuration)\LGIdd
|
||||
</PostBuildEvent>
|
||||
<Manifest />
|
||||
<Manifest>
|
||||
<EnableDpiAwareness>false</EnableDpiAwareness>
|
||||
<InputResourceManifests>$(ProjectDir)HighDPI.manifest</InputResourceManifests>
|
||||
<EnableDpiAwareness>PerMonitorHighDPIAware</EnableDpiAwareness>
|
||||
</Manifest>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
@@ -119,8 +118,7 @@ copy /Y "$(ProjectDir)VERSION" "$(SolutionDir)$(Platform)\$(Configuration)\LGIdd
|
||||
</PostBuildEvent>
|
||||
<Manifest />
|
||||
<Manifest>
|
||||
<EnableDpiAwareness>false</EnableDpiAwareness>
|
||||
<InputResourceManifests>$(ProjectDir)HighDPI.manifest</InputResourceManifests>
|
||||
<EnableDpiAwareness>PerMonitorHighDPIAware</EnableDpiAwareness>
|
||||
</Manifest>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
@@ -146,8 +144,7 @@ copy /Y "$(ProjectDir)VERSION" "$(SolutionDir)$(Platform)\$(Configuration)\LGIdd
|
||||
</PostBuildEvent>
|
||||
<Manifest />
|
||||
<Manifest>
|
||||
<EnableDpiAwareness>false</EnableDpiAwareness>
|
||||
<InputResourceManifests>$(ProjectDir)HighDPI.manifest</InputResourceManifests>
|
||||
<EnableDpiAwareness>PerMonitorHighDPIAware</EnableDpiAwareness>
|
||||
</Manifest>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
@@ -177,8 +174,7 @@ copy /Y "$(ProjectDir)VERSION" "$(SolutionDir)$(Platform)\$(Configuration)\LGIdd
|
||||
</PostBuildEvent>
|
||||
<Manifest />
|
||||
<Manifest>
|
||||
<EnableDpiAwareness>false</EnableDpiAwareness>
|
||||
<InputResourceManifests>$(ProjectDir)HighDPI.manifest</InputResourceManifests>
|
||||
<EnableDpiAwareness>PerMonitorHighDPIAware</EnableDpiAwareness>
|
||||
</Manifest>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
@@ -211,7 +207,6 @@ copy /Y "$(ProjectDir)VERSION" "$(SolutionDir)$(Platform)\$(Configuration)\LGIdd
|
||||
<ClInclude Include="CRegistrySettings.h" />
|
||||
<ClInclude Include="CStaticWidget.h" />
|
||||
<ClInclude Include="CWidget.h" />
|
||||
<ClInclude Include="Resources.h" />
|
||||
<ClInclude Include="UIHelpers.h" />
|
||||
<ClInclude Include="CWindow.h" />
|
||||
</ItemGroup>
|
||||
@@ -221,9 +216,6 @@ 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">
|
||||
|
||||
@@ -100,9 +100,6 @@
|
||||
<ClInclude Include="CCheckbox.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Resources.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
@@ -112,7 +109,4 @@
|
||||
<Filter>Resource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Manifest Include="HighDPI.manifest" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -1,25 +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
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define ID_MAIN_ICON 1
|
||||
#define ID_GPU_ICON 2
|
||||
#define ID_NO_GPU_ICON 3
|
||||
@@ -120,10 +120,6 @@ int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _
|
||||
if (!g_pipe.Init())
|
||||
return EXIT_FAILURE;
|
||||
|
||||
window.onSettingChange([]() {
|
||||
g_pipe.ReloadSettings();
|
||||
});
|
||||
|
||||
HANDLE hWait;
|
||||
if (!RegisterWaitForSingleObject(&hWait, hParent.Get(), DestroyNotifyWindow, &window, INFINITE, WT_EXECUTEONLYONCE))
|
||||
DEBUG_ERROR_HR(GetLastError(), "Failed to RegisterWaitForSingleObject");
|
||||
|
||||
@@ -22,11 +22,8 @@
|
||||
#include "winuser.h"
|
||||
#include "winver.h"
|
||||
#include "VersionInfo.h"
|
||||
#include "Resources.h"
|
||||
|
||||
ID_MAIN_ICON ICON "../../resources/icon.ico"
|
||||
ID_GPU_ICON ICON "../../resources/icon-gpu.ico"
|
||||
ID_NO_GPU_ICON ICON "../../resources/icon-nogpu.ico"
|
||||
IDI_APPLICATION ICON "../../resources/icon.ico"
|
||||
|
||||
#define STRINGIFY2(s) L#s
|
||||
#define STRINGIFY(s) STRINGIFY2(s)
|
||||
|
||||
Submodule repos/wayland-protocols updated: 02e63e74a8...d324986823
Binary file not shown.
|
Before Width: | Height: | Size: 88 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 88 KiB |
Reference in New Issue
Block a user