mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-06-08 07:44:32 +00:00
[idd] helper: update icon tip to reflect GPU state
This commit is contained in:
@@ -49,7 +49,7 @@ bool CNotifyWindow::registerClass()
|
|||||||
}
|
}
|
||||||
|
|
||||||
CNotifyWindow::CNotifyWindow() : m_iconData({ 0 }), m_iconRegistered(false),
|
CNotifyWindow::CNotifyWindow() : m_iconData({ 0 }), m_iconRegistered(false),
|
||||||
m_noGPUQueued(false), m_menu(CreatePopupMenu()), closeRequested(false)
|
m_menu(CreatePopupMenu()), closeRequested(false)
|
||||||
{
|
{
|
||||||
CreateWindowEx(0, MAKEINTATOM(s_atom), NULL,
|
CreateWindowEx(0, MAKEINTATOM(s_atom), NULL,
|
||||||
0, 0, 0, 0, 0, NULL, NULL, hInstance, this);
|
0, 0, 0, 0, 0, NULL, NULL, hInstance, this);
|
||||||
@@ -82,7 +82,7 @@ LRESULT CNotifyWindow::handleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case WM_NO_GPU:
|
case WM_NO_GPU:
|
||||||
handleNoGPUNotification();
|
handleGPUNotification((bool)wParam);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -152,7 +152,7 @@ void CNotifyWindow::registerIcon()
|
|||||||
{
|
{
|
||||||
m_iconData.cbSize = sizeof m_iconData;
|
m_iconData.cbSize = sizeof m_iconData;
|
||||||
m_iconData.hWnd = m_hwnd;
|
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.uCallbackMessage = WM_NOTIFY_ICON;
|
||||||
m_iconData.hIcon = LoadIcon(hInstance, IDI_APPLICATION);
|
m_iconData.hIcon = LoadIcon(hInstance, IDI_APPLICATION);
|
||||||
m_iconData.uVersion = NOTIFYICON_VERSION_4;
|
m_iconData.uVersion = NOTIFYICON_VERSION_4;
|
||||||
@@ -168,23 +168,36 @@ void CNotifyWindow::registerIcon()
|
|||||||
if (!Shell_NotifyIcon(NIM_SETVERSION, &m_iconData))
|
if (!Shell_NotifyIcon(NIM_SETVERSION, &m_iconData))
|
||||||
DEBUG_ERROR_HR(GetLastError(), "Shell_NotifyIcon(NIM_SETVERSION)");
|
DEBUG_ERROR_HR(GetLastError(), "Shell_NotifyIcon(NIM_SETVERSION)");
|
||||||
|
|
||||||
if (m_noGPUQueued)
|
if (m_gpuQueue)
|
||||||
{
|
{
|
||||||
m_noGPUQueued = false;
|
handleGPUNotification(*m_gpuQueue);
|
||||||
handleNoGPUNotification();
|
m_gpuQueue.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CNotifyWindow::noGPUNotification()
|
void CNotifyWindow::setGPU(bool hasGPU)
|
||||||
{
|
{
|
||||||
if (m_iconRegistered)
|
if (m_iconRegistered)
|
||||||
PostMessage(m_hwnd, WM_NO_GPU, 0, 0);
|
PostMessage(m_hwnd, WM_NO_GPU, hasGPU, 0);
|
||||||
else
|
else
|
||||||
m_noGPUQueued = true;
|
m_gpuQueue.emplace(hasGPU);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CNotifyWindow::handleNoGPUNotification()
|
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 (!Shell_NotifyIcon(NIM_MODIFY, &m_iconData))
|
||||||
|
{
|
||||||
|
DEBUG_ERROR_HR(GetLastError(), "Shell_NotifyIcon(NIM_ADD)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasGPU)
|
||||||
|
return;
|
||||||
|
|
||||||
CRegistrySettings settings;
|
CRegistrySettings settings;
|
||||||
LSTATUS error = settings.open();
|
LSTATUS error = settings.open();
|
||||||
if (error != ERROR_SUCCESS)
|
if (error != ERROR_SUCCESS)
|
||||||
@@ -197,7 +210,7 @@ void CNotifyWindow::handleNoGPUNotification()
|
|||||||
NOTIFYICONDATA nid;
|
NOTIFYICONDATA nid;
|
||||||
memcpy(&nid, &m_iconData, sizeof nid);
|
memcpy(&nid, &m_iconData, sizeof nid);
|
||||||
|
|
||||||
nid.uFlags = NIF_INFO;
|
nid.uFlags = NIF_INFO | NIF_SHOWTIP;
|
||||||
nid.dwInfoFlags = NIIF_WARNING;
|
nid.dwInfoFlags = NIIF_WARNING;
|
||||||
StringCbCopy(nid.szInfoTitle, sizeof nid.szInfoTitle, L"No GPU found!");
|
StringCbCopy(nid.szInfoTitle, sizeof nid.szInfoTitle, L"No GPU found!");
|
||||||
StringCbCopy(nid.szInfo, sizeof nid.szInfo,
|
StringCbCopy(nid.szInfo, sizeof nid.szInfo,
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "CWindow.h"
|
#include "CWindow.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
class CConfigWindow;
|
class CConfigWindow;
|
||||||
|
|
||||||
@@ -31,14 +32,14 @@ class CNotifyWindow : public CWindow
|
|||||||
|
|
||||||
NOTIFYICONDATA m_iconData;
|
NOTIFYICONDATA m_iconData;
|
||||||
bool m_iconRegistered;
|
bool m_iconRegistered;
|
||||||
bool m_noGPUQueued;
|
std::optional<bool> m_gpuQueue;
|
||||||
HMENU m_menu;
|
HMENU m_menu;
|
||||||
bool closeRequested;
|
bool closeRequested;
|
||||||
std::unique_ptr<CConfigWindow> m_config;
|
std::unique_ptr<CConfigWindow> m_config;
|
||||||
|
|
||||||
LRESULT onNotifyIcon(UINT uEvent, WORD wIconId, int x, int y);
|
LRESULT onNotifyIcon(UINT uEvent, WORD wIconId, int x, int y);
|
||||||
void registerIcon();
|
void registerIcon();
|
||||||
void handleNoGPUNotification();
|
void handleGPUNotification(bool hasGPU);
|
||||||
|
|
||||||
virtual LRESULT handleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) override;
|
virtual LRESULT handleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) override;
|
||||||
virtual LRESULT onCreate() override;
|
virtual LRESULT onCreate() override;
|
||||||
@@ -64,7 +65,7 @@ public:
|
|||||||
|
|
||||||
static bool registerClass();
|
static bool registerClass();
|
||||||
|
|
||||||
void noGPUNotification();
|
void setGPU(bool hasGPU);
|
||||||
|
|
||||||
HWND hwndDialog();
|
HWND hwndDialog();
|
||||||
void close();
|
void close();
|
||||||
|
|||||||
@@ -308,6 +308,5 @@ void CPipeClient::HandleSetDisplayMode(const LGPipeMsg& msg)
|
|||||||
|
|
||||||
void CPipeClient::HandleGPUStatus(const LGPipeMsg& msg)
|
void CPipeClient::HandleGPUStatus(const LGPipeMsg& msg)
|
||||||
{
|
{
|
||||||
if (msg.gpuStatus.software)
|
CNotifyWindow::instance().setGPU(!msg.gpuStatus.software);
|
||||||
CNotifyWindow::instance().noGPUNotification();
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user