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