mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-25 04:38:23 +00:00
Check for composition in WM_NCACTIVATE.
This commit is contained in:
parent
95eab45108
commit
c7ed36d558
@ -42,12 +42,14 @@ f_WindowsCreateStringReference WindowsCreateStringReference;
|
||||
f_WindowsDeleteString WindowsDeleteString;
|
||||
f_PropVariantToString PropVariantToString;
|
||||
f_PSStringFromPropertyKey PSStringFromPropertyKey;
|
||||
f_DwmIsCompositionEnabled DwmIsCompositionEnabled;
|
||||
|
||||
HINSTANCE LibUxTheme;
|
||||
HINSTANCE LibShell32;
|
||||
HINSTANCE LibWtsApi32;
|
||||
HINSTANCE LibPropSys;
|
||||
HINSTANCE LibComBase;
|
||||
HINSTANCE LibDwmApi;
|
||||
|
||||
void start() {
|
||||
init();
|
||||
@ -84,6 +86,9 @@ void start() {
|
||||
load(LibComBase, "WindowsCreateStringReference", WindowsCreateStringReference);
|
||||
load(LibComBase, "WindowsDeleteString", WindowsDeleteString);
|
||||
}
|
||||
|
||||
LibDwmApi = LoadLibrary(L"DWMAPI.DLL");
|
||||
load(LibDwmApi, "DwmIsCompositionEnabled", DwmIsCompositionEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include <windows.h>
|
||||
#include <shlobj.h>
|
||||
#include <roapi.h>
|
||||
#include <dwmapi.h>
|
||||
|
||||
namespace Platform {
|
||||
namespace Dlls {
|
||||
@ -17,7 +18,7 @@ namespace Dlls {
|
||||
void init();
|
||||
|
||||
// KERNEL32.DLL
|
||||
typedef BOOL (FAR STDAPICALLTYPE *f_SetDllDirectory)(LPCWSTR lpPathName);
|
||||
using f_SetDllDirectory = BOOL(FAR STDAPICALLTYPE*)(LPCWSTR lpPathName);
|
||||
extern f_SetDllDirectory SetDllDirectory;
|
||||
|
||||
void start();
|
||||
@ -31,59 +32,62 @@ bool load(HINSTANCE library, LPCSTR name, Function &func) {
|
||||
}
|
||||
|
||||
// UXTHEME.DLL
|
||||
typedef HRESULT (FAR STDAPICALLTYPE *f_SetWindowTheme)(HWND hWnd, LPCWSTR pszSubAppName, LPCWSTR pszSubIdList);
|
||||
using f_SetWindowTheme = HRESULT(FAR STDAPICALLTYPE*)(HWND hWnd, LPCWSTR pszSubAppName, LPCWSTR pszSubIdList);
|
||||
extern f_SetWindowTheme SetWindowTheme;
|
||||
|
||||
// SHELL32.DLL
|
||||
typedef HRESULT (FAR STDAPICALLTYPE *f_SHAssocEnumHandlers)(PCWSTR pszExtra, ASSOC_FILTER afFilter, IEnumAssocHandlers **ppEnumHandler);
|
||||
using f_SHAssocEnumHandlers = HRESULT(FAR STDAPICALLTYPE*)(PCWSTR pszExtra, ASSOC_FILTER afFilter, IEnumAssocHandlers **ppEnumHandler);
|
||||
extern f_SHAssocEnumHandlers SHAssocEnumHandlers;
|
||||
|
||||
typedef HRESULT (FAR STDAPICALLTYPE *f_SHCreateItemFromParsingName)(PCWSTR pszPath, IBindCtx *pbc, REFIID riid, void **ppv);
|
||||
using f_SHCreateItemFromParsingName = HRESULT(FAR STDAPICALLTYPE*)(PCWSTR pszPath, IBindCtx *pbc, REFIID riid, void **ppv);
|
||||
extern f_SHCreateItemFromParsingName SHCreateItemFromParsingName;
|
||||
|
||||
typedef HRESULT (FAR STDAPICALLTYPE *f_SHOpenWithDialog)(HWND hwndParent, const OPENASINFO *poainfo);
|
||||
using f_SHOpenWithDialog = HRESULT(FAR STDAPICALLTYPE*)(HWND hwndParent, const OPENASINFO *poainfo);
|
||||
extern f_SHOpenWithDialog SHOpenWithDialog;
|
||||
|
||||
typedef HRESULT (FAR STDAPICALLTYPE *f_OpenAs_RunDLL)(HWND hWnd, HINSTANCE hInstance, LPCWSTR lpszCmdLine, int nCmdShow);
|
||||
using f_OpenAs_RunDLL = HRESULT(FAR STDAPICALLTYPE*)(HWND hWnd, HINSTANCE hInstance, LPCWSTR lpszCmdLine, int nCmdShow);
|
||||
extern f_OpenAs_RunDLL OpenAs_RunDLL;
|
||||
|
||||
typedef HRESULT (FAR STDAPICALLTYPE *f_SHQueryUserNotificationState)(QUERY_USER_NOTIFICATION_STATE *pquns);
|
||||
using f_SHQueryUserNotificationState = HRESULT(FAR STDAPICALLTYPE*)(QUERY_USER_NOTIFICATION_STATE *pquns);
|
||||
extern f_SHQueryUserNotificationState SHQueryUserNotificationState;
|
||||
|
||||
typedef void (FAR STDAPICALLTYPE *f_SHChangeNotify)(LONG wEventId, UINT uFlags, __in_opt LPCVOID dwItem1, __in_opt LPCVOID dwItem2);
|
||||
using f_SHChangeNotify = void(FAR STDAPICALLTYPE*)(LONG wEventId, UINT uFlags, __in_opt LPCVOID dwItem1, __in_opt LPCVOID dwItem2);
|
||||
extern f_SHChangeNotify SHChangeNotify;
|
||||
|
||||
typedef HRESULT (FAR STDAPICALLTYPE *f_SetCurrentProcessExplicitAppUserModelID)(__in PCWSTR AppID);
|
||||
using f_SetCurrentProcessExplicitAppUserModelID = HRESULT(FAR STDAPICALLTYPE*)(__in PCWSTR AppID);
|
||||
extern f_SetCurrentProcessExplicitAppUserModelID SetCurrentProcessExplicitAppUserModelID;
|
||||
|
||||
// WTSAPI32.DLL
|
||||
|
||||
typedef BOOL (FAR STDAPICALLTYPE *f_WTSRegisterSessionNotification)(HWND hWnd, DWORD dwFlags);
|
||||
using f_WTSRegisterSessionNotification = BOOL(FAR STDAPICALLTYPE*)(HWND hWnd, DWORD dwFlags);
|
||||
extern f_WTSRegisterSessionNotification WTSRegisterSessionNotification;
|
||||
|
||||
typedef BOOL (FAR STDAPICALLTYPE *f_WTSUnRegisterSessionNotification)(HWND hWnd);
|
||||
using f_WTSUnRegisterSessionNotification = BOOL(FAR STDAPICALLTYPE*)(HWND hWnd);
|
||||
extern f_WTSUnRegisterSessionNotification WTSUnRegisterSessionNotification;
|
||||
|
||||
// PROPSYS.DLL
|
||||
|
||||
typedef HRESULT (FAR STDAPICALLTYPE *f_PropVariantToString)(_In_ REFPROPVARIANT propvar, _Out_writes_(cch) PWSTR psz, _In_ UINT cch);
|
||||
using f_PropVariantToString = HRESULT(FAR STDAPICALLTYPE*)(_In_ REFPROPVARIANT propvar, _Out_writes_(cch) PWSTR psz, _In_ UINT cch);
|
||||
extern f_PropVariantToString PropVariantToString;
|
||||
|
||||
typedef HRESULT (FAR STDAPICALLTYPE *f_PSStringFromPropertyKey)(_In_ REFPROPERTYKEY pkey, _Out_writes_(cch) LPWSTR psz, _In_ UINT cch);
|
||||
using f_PSStringFromPropertyKey = HRESULT(FAR STDAPICALLTYPE*)(_In_ REFPROPERTYKEY pkey, _Out_writes_(cch) LPWSTR psz, _In_ UINT cch);
|
||||
extern f_PSStringFromPropertyKey PSStringFromPropertyKey;
|
||||
|
||||
// COMBASE.DLL
|
||||
|
||||
typedef HRESULT (FAR STDAPICALLTYPE *f_RoGetActivationFactory)(_In_ HSTRING activatableClassId, _In_ REFIID iid, _COM_Outptr_ void ** factory);
|
||||
using f_RoGetActivationFactory = HRESULT(FAR STDAPICALLTYPE*)(_In_ HSTRING activatableClassId, _In_ REFIID iid, _COM_Outptr_ void ** factory);
|
||||
extern f_RoGetActivationFactory RoGetActivationFactory;
|
||||
|
||||
typedef HRESULT (FAR STDAPICALLTYPE *f_WindowsCreateStringReference)(_In_reads_opt_(length + 1) PCWSTR sourceString, UINT32 length, _Out_ HSTRING_HEADER * hstringHeader, _Outptr_result_maybenull_ _Result_nullonfailure_ HSTRING * string);
|
||||
using f_WindowsCreateStringReference = HRESULT(FAR STDAPICALLTYPE*)(_In_reads_opt_(length + 1) PCWSTR sourceString, UINT32 length, _Out_ HSTRING_HEADER * hstringHeader, _Outptr_result_maybenull_ _Result_nullonfailure_ HSTRING * string);
|
||||
extern f_WindowsCreateStringReference WindowsCreateStringReference;
|
||||
|
||||
typedef HRESULT (FAR STDAPICALLTYPE *f_WindowsDeleteString)(_In_opt_ HSTRING string);
|
||||
using f_WindowsDeleteString = HRESULT(FAR STDAPICALLTYPE*)(_In_opt_ HSTRING string);
|
||||
extern f_WindowsDeleteString WindowsDeleteString;
|
||||
|
||||
// DWMAPI.DLL
|
||||
|
||||
using f_DwmIsCompositionEnabled = HRESULT(FAR STDAPICALLTYPE*)(_Out_ BOOL* pfEnabled);
|
||||
extern f_DwmIsCompositionEnabled DwmIsCompositionEnabled;
|
||||
|
||||
} // namespace Dlls
|
||||
} // namespace Platform
|
||||
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "platform/win/windows_event_filter.h"
|
||||
|
||||
#include "platform/win/windows_dlls.h"
|
||||
#include "mainwindow.h"
|
||||
#include "auth_session.h"
|
||||
|
||||
@ -17,6 +18,15 @@ EventFilter *instance = nullptr;
|
||||
|
||||
int menuShown = 0, menuHidden = 0;
|
||||
|
||||
bool IsCompositionEnabled() {
|
||||
if (!Dlls::DwmIsCompositionEnabled) {
|
||||
return false;
|
||||
}
|
||||
auto result = BOOL(FALSE);
|
||||
const auto success = (Dlls::DwmIsCompositionEnabled(&result) == S_OK);
|
||||
return success && result;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
EventFilter *EventFilter::createInstance() {
|
||||
@ -117,8 +127,13 @@ bool EventFilter::mainWindowEvent(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
|
||||
}
|
||||
|
||||
case WM_NCACTIVATE: {
|
||||
auto res = DefWindowProc(hWnd, msg, wParam, -1);
|
||||
if (result) *result = res;
|
||||
if (IsCompositionEnabled()) {
|
||||
const auto res = DefWindowProc(hWnd, msg, wParam, -1);
|
||||
if (result) *result = res;
|
||||
} else {
|
||||
// Thanks https://github.com/melak47/BorderlessWindow
|
||||
if (result) *result = 1;
|
||||
}
|
||||
} return true;
|
||||
|
||||
case WM_WINDOWPOSCHANGING:
|
||||
|
Loading…
Reference in New Issue
Block a user