fix missing tray icon bug
This commit is contained in:
@@ -23,10 +23,8 @@
|
|||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include "AsuroTool.h"
|
#include "AsuroTool.h"
|
||||||
|
|
||||||
class __declspec(uuid("3bc52579-15fd-43bb-9686-6273c238535e")) TrayGUID;
|
const UINT TRAY_ID = 420;
|
||||||
|
const UINT WMAPP_NOTIFYCALLBACK = WM_APP + 1;
|
||||||
UINT const WMAPP_NOTIFYCALLBACK = WM_APP + 1;
|
|
||||||
UINT const WMAPP_HIDEFLYOUT = WM_APP + 2;
|
|
||||||
|
|
||||||
// Globals for use in callbacks
|
// Globals for use in callbacks
|
||||||
DrawData* gDrawData;
|
DrawData* gDrawData;
|
||||||
@@ -75,8 +73,8 @@ void init(DrawData& drawData, ApplicationData& appData)
|
|||||||
// Set tray icon
|
// Set tray icon
|
||||||
NOTIFYICONDATA nid = { sizeof(nid) };
|
NOTIFYICONDATA nid = { sizeof(nid) };
|
||||||
nid.hWnd = drawData.window_handle;
|
nid.hWnd = drawData.window_handle;
|
||||||
nid.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE | NIF_SHOWTIP | NIF_GUID;
|
nid.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE | NIF_SHOWTIP;
|
||||||
nid.guidItem = __uuidof(TrayGUID);
|
nid.uID = TRAY_ID;
|
||||||
nid.uCallbackMessage = WMAPP_NOTIFYCALLBACK;
|
nid.uCallbackMessage = WMAPP_NOTIFYCALLBACK;
|
||||||
|
|
||||||
HRESULT iconResult;
|
HRESULT iconResult;
|
||||||
@@ -123,10 +121,6 @@ void draw(DrawData& drawData, ApplicationData& appData)
|
|||||||
{
|
{
|
||||||
justDocked = false;
|
justDocked = false;
|
||||||
|
|
||||||
// sad :(
|
|
||||||
gDrawData = &drawData;
|
|
||||||
gAppData = &appData;
|
|
||||||
|
|
||||||
// Actual Drawing
|
// Actual Drawing
|
||||||
if (isHidden)
|
if (isHidden)
|
||||||
{
|
{
|
||||||
@@ -167,9 +161,9 @@ void cleanup(DrawData& drawData, ApplicationData& appData)
|
|||||||
{
|
{
|
||||||
// Remove tray icon
|
// Remove tray icon
|
||||||
NOTIFYICONDATA nid = { sizeof(nid) };
|
NOTIFYICONDATA nid = { sizeof(nid) };
|
||||||
nid.uFlags = NIF_GUID;
|
nid.hWnd = drawData.window_handle;
|
||||||
nid.guidItem = __uuidof(TrayGUID);
|
nid.uID = TRAY_ID;
|
||||||
bool test = Shell_NotifyIcon(NIM_DELETE, &nid);
|
Shell_NotifyIcon(NIM_DELETE, &nid);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImVec2 menuBar(DrawData& drawData, ApplicationData& appData)
|
ImVec2 menuBar(DrawData& drawData, ApplicationData& appData)
|
||||||
@@ -181,9 +175,7 @@ ImVec2 menuBar(DrawData& drawData, ApplicationData& appData)
|
|||||||
{
|
{
|
||||||
if (ImGui::BeginMenu("Settings"))
|
if (ImGui::BeginMenu("Settings"))
|
||||||
{
|
{
|
||||||
bool prevDocked = appData.settings.docked;
|
if (ImGui::Checkbox("Docked", &appData.settings.docked))
|
||||||
ImGui::Checkbox("Docked", &appData.settings.docked);
|
|
||||||
if (appData.settings.docked != prevDocked)
|
|
||||||
{
|
{
|
||||||
closeMenu = true;
|
closeMenu = true;
|
||||||
updateDocked(drawData, appData);
|
updateDocked(drawData, appData);
|
||||||
@@ -378,12 +370,13 @@ LRESULT CALLBACK trayIconEventHandler(int code, WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
if (data->message == WMAPP_NOTIFYCALLBACK)
|
if (data->message == WMAPP_NOTIFYCALLBACK)
|
||||||
{
|
{
|
||||||
switch (data->lParam)
|
auto id = HIWORD(data->lParam);
|
||||||
|
auto trayEvent = LOWORD(data->lParam);
|
||||||
|
|
||||||
|
if (id == TRAY_ID && trayEvent == WM_LBUTTONUP)
|
||||||
{
|
{
|
||||||
case NIN_SELECT:
|
|
||||||
glfwShowWindow(gDrawData->window);
|
glfwShowWindow(gDrawData->window);
|
||||||
glfwRestoreWindow(gDrawData->window);
|
glfwRestoreWindow(gDrawData->window);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,4 +13,5 @@ ImVec2 menuBar(DrawData& drawData, ApplicationData& appData);
|
|||||||
ImVec2 audioDeviceWindow(ApplicationData& appData, std::vector<AudioDevice>& deviceList, const char* title);
|
ImVec2 audioDeviceWindow(ApplicationData& appData, std::vector<AudioDevice>& deviceList, const char* title);
|
||||||
void drawCircle(float radius, ImU32 color);
|
void drawCircle(float radius, ImU32 color);
|
||||||
|
|
||||||
|
void GenerateTrayUUID(UUID* uuid);
|
||||||
LRESULT trayIconEventHandler(int code, WPARAM wParam, LPARAM lParam);
|
LRESULT trayIconEventHandler(int code, WPARAM wParam, LPARAM lParam);
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ void loadAudioDevices(AudioData& audioData, std::vector<AudioDevice>& deviceList
|
|||||||
deviceList.clear();
|
deviceList.clear();
|
||||||
|
|
||||||
HRESULT err;
|
HRESULT err;
|
||||||
IMMDeviceCollection* deviceCollection = NULL;
|
IMMDeviceCollection* deviceCollection = nullptr;
|
||||||
|
|
||||||
err = audioData.deviceEnumerator->EnumAudioEndpoints(deviceType, DEVICE_STATE_ACTIVE | DEVICE_STATE_DISABLED, &deviceCollection);
|
err = audioData.deviceEnumerator->EnumAudioEndpoints(deviceType, DEVICE_STATE_ACTIVE | DEVICE_STATE_DISABLED, &deviceCollection);
|
||||||
if (isError(err, "Failed to enumerate audio devices: ")) return;
|
if (isError(err, "Failed to enumerate audio devices: ")) return;
|
||||||
@@ -40,7 +40,7 @@ void loadAudioDevices(AudioData& audioData, std::vector<AudioDevice>& deviceList
|
|||||||
err = deviceCollection->GetCount(&deviceCount);
|
err = deviceCollection->GetCount(&deviceCount);
|
||||||
if (isError(err, "Failed to count audio devices: ")) return;
|
if (isError(err, "Failed to count audio devices: ")) return;
|
||||||
|
|
||||||
IMMDevice* defaultConsoleDevice = NULL;
|
IMMDevice* defaultConsoleDevice = nullptr;
|
||||||
LPWSTR defaultConsoleId = nullptr;
|
LPWSTR defaultConsoleId = nullptr;
|
||||||
err = audioData.deviceEnumerator->GetDefaultAudioEndpoint(deviceType, ERole::eConsole, &defaultConsoleDevice);
|
err = audioData.deviceEnumerator->GetDefaultAudioEndpoint(deviceType, ERole::eConsole, &defaultConsoleDevice);
|
||||||
if (!FAILED(err))
|
if (!FAILED(err))
|
||||||
@@ -48,7 +48,7 @@ void loadAudioDevices(AudioData& audioData, std::vector<AudioDevice>& deviceList
|
|||||||
defaultConsoleDevice->GetId(&defaultConsoleId);
|
defaultConsoleDevice->GetId(&defaultConsoleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
IMMDevice* defaultMediaOutput = NULL;
|
IMMDevice* defaultMediaOutput = nullptr;
|
||||||
LPWSTR defaultMediaId = nullptr;
|
LPWSTR defaultMediaId = nullptr;
|
||||||
err = audioData.deviceEnumerator->GetDefaultAudioEndpoint(deviceType, ERole::eMultimedia, &defaultMediaOutput);
|
err = audioData.deviceEnumerator->GetDefaultAudioEndpoint(deviceType, ERole::eMultimedia, &defaultMediaOutput);
|
||||||
if (!FAILED(err))
|
if (!FAILED(err))
|
||||||
@@ -56,7 +56,7 @@ void loadAudioDevices(AudioData& audioData, std::vector<AudioDevice>& deviceList
|
|||||||
defaultMediaOutput->GetId(&defaultMediaId);
|
defaultMediaOutput->GetId(&defaultMediaId);
|
||||||
}
|
}
|
||||||
|
|
||||||
IMMDevice* defaultCommunicationOutput = NULL;
|
IMMDevice* defaultCommunicationOutput = nullptr;
|
||||||
LPWSTR defaultCommunicationId = nullptr;
|
LPWSTR defaultCommunicationId = nullptr;
|
||||||
err = audioData.deviceEnumerator->GetDefaultAudioEndpoint(deviceType, ERole::eCommunications, &defaultCommunicationOutput);
|
err = audioData.deviceEnumerator->GetDefaultAudioEndpoint(deviceType, ERole::eCommunications, &defaultCommunicationOutput);
|
||||||
if (!FAILED(err))
|
if (!FAILED(err))
|
||||||
@@ -150,7 +150,7 @@ HRESULT getDevicePropertyString(IPropertyStore* propertyStore, const PROPERTYKEY
|
|||||||
|
|
||||||
void setDefaultAudioDevice(AudioData& audioData, const wchar_t* deviceId, ERole role)
|
void setDefaultAudioDevice(AudioData& audioData, const wchar_t* deviceId, ERole role)
|
||||||
{
|
{
|
||||||
IPolicyConfigVista* pPolicyConfig;
|
IPolicyConfigVista* pPolicyConfig = nullptr;
|
||||||
|
|
||||||
HRESULT hr = CoCreateInstance(__uuidof(CPolicyConfigVistaClient), NULL, CLSCTX_ALL, __uuidof(IPolicyConfigVista), (LPVOID*)&pPolicyConfig);
|
HRESULT hr = CoCreateInstance(__uuidof(CPolicyConfigVistaClient), NULL, CLSCTX_ALL, __uuidof(IPolicyConfigVista), (LPVOID*)&pPolicyConfig);
|
||||||
if (!isError(hr, "Failed to set default audio device: "))
|
if (!isError(hr, "Failed to set default audio device: "))
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ HRESULT __stdcall AudioNotificationListener::QueryInterface(REFIID riid, void**
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*ppvObject = NULL;
|
*ppvObject = nullptr;
|
||||||
return E_NOINTERFACE;
|
return E_NOINTERFACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ void setAutostart(bool newValue)
|
|||||||
|
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
HKEY runKey = NULL;
|
HKEY runKey = nullptr;
|
||||||
hr = RegCreateKey(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", &runKey);
|
hr = RegCreateKey(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", &runKey);
|
||||||
if (isError(hr, "Failed to find/create autostart run key: ")) return;
|
if (isError(hr, "Failed to find/create autostart run key: ")) return;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user