Skip to content

Commit 7b8f220

Browse files
authored
Update dwm-bs.h
1 parent 248a86d commit 7b8f220

File tree

1 file changed

+37
-23
lines changed

1 file changed

+37
-23
lines changed

dwm-bs/dwm-bs.h

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
#define HK_ID 1
77

88
HWND HWNDPrev = NULL;
9-
WCHAR className[32];
109
HWINEVENTHOOK hHook;
11-
BOOL lpol, tpol;
10+
BOOL tPol, tPeek, isEnabled;
1211

1312

1413
DWORD GetPID(const char* processName) {
@@ -40,7 +39,7 @@ DWORD GetPID(const char* processName) {
4039

4140
const char* GetExcludeList()
4241
{
43-
static char pBuffer[64];
42+
static char pBuffer[64]; // Usamos static para que la variable persista fuera del alcance de la función
4443
DWORD pSize = sizeof(pBuffer);
4544

4645
// Leer la lista de procesos excluidos
@@ -55,6 +54,7 @@ const char* GetExcludeList()
5554

5655
if (RegQueryValueExA(hKey, "ExclusionList", NULL, &valueType, (LPBYTE)pBuffer, &pSize) != ERROR_SUCCESS){
5756
const char* initialValue = "explorer.exe\0\0";
57+
5858
RegSetValueExA(hKey, "ExclusionList", 0, REG_MULTI_SZ, (const BYTE*)initialValue, strlen(initialValue));
5959
}
6060

@@ -64,43 +64,55 @@ const char* GetExcludeList()
6464
return pBuffer;
6565
}
6666

67-
void _PoL(HWND hwnd, const char* Option)
67+
void _NCRP(HWND hwnd, const char* Option)
6868
{
69-
//politica de renderizado y transisiones
69+
//politica de renderizado
7070
if (strcmp(Option, "Enable") == 0) {
7171
DWMNCRENDERINGPOLICY rNCRP = DWMNCRP_ENABLED;
72-
tpol = FALSE;
7372
DwmSetWindowAttribute(hwnd, DWMWA_NCRENDERING_POLICY, &rNCRP, sizeof(rNCRP));
74-
DwmSetWindowAttribute(hwnd, DWMWA_TRANSITIONS_FORCEDISABLED, &tpol, sizeof(tpol));
73+
7574
} else if (strcmp(Option, "Disable") == 0) {
7675
DWMNCRENDERINGPOLICY NCRP = DWMNCRP_DISABLED;
77-
lpol = TRUE;
7876
DwmSetWindowAttribute(hwnd, DWMWA_NCRENDERING_POLICY, &NCRP, sizeof(NCRP));
79-
DwmSetWindowAttribute(hwnd, DWMWA_TRANSITIONS_FORCEDISABLED, &lpol, sizeof(lpol));
8077
}
8178
}
8279

83-
void _DisableBlurBehind(HWND hWnd)
80+
void _ATTRIBS_OFF(HWND hwnd)
8481
{
85-
//politica de transparencia
86-
DWM_BLURBEHIND bb = {0};
87-
bb.dwFlags = DWM_BB_ENABLE;
88-
bb.fEnable = FALSE;
89-
bb.hRgnBlur = NULL;
82+
//politica de transisiones, icon_peek,
83+
tPol = TRUE;
84+
tPeek = FALSE;
85+
DwmSetWindowAttribute(hwnd, DWMWA_TRANSITIONS_FORCEDISABLED, &tPol, sizeof(tPol));
86+
DwmSetWindowAttribute(hwnd, DWMWA_DISALLOW_PEEK, &tPeek, sizeof(tPeek));
87+
DwmSetWindowAttribute(hwnd, DWMWA_FORCE_ICONIC_REPRESENTATION, &tPol, sizeof(tPol));
88+
}
9089

91-
DwmEnableBlurBehindWindow(hWnd, &bb);
90+
void _ATTRIBS_ON(HWND hwnd)
91+
{
92+
tPol = FALSE;
93+
tPeek = TRUE;
94+
DwmSetWindowAttribute(hwnd, DWMWA_TRANSITIONS_FORCEDISABLED, &tPol, sizeof(tPol));
95+
DwmSetWindowAttribute(hwnd, DWMWA_DISALLOW_PEEK, &tPeek, sizeof(tPeek));
96+
DwmSetWindowAttribute(hwnd, DWMWA_FORCE_ICONIC_REPRESENTATION, &tPol, sizeof(tPol));
9297
}
9398

9499
BOOL IsExcludeHWND(HWND hWnd_ex)
95100
{
101+
102+
// Verificar si la ventana tiene la renderización habilitada
103+
DwmGetWindowAttribute(hWnd_ex, DWMWA_NCRENDERING_ENABLED, &isEnabled, sizeof(isEnabled));
104+
if(isEnabled == FALSE) {
105+
return TRUE;
106+
}
107+
96108
DWORD pid;
97109
GetWindowThreadProcessId(hWnd_ex, &pid);
98110

99111
const char* pBuffer = GetExcludeList();
100112

101113
// Verificar si el proceso de la ventana está en la lista de exclusión
102114
while (*pBuffer) {
103-
DWORD pid_ex = GetPID(pBuffer);
115+
DWORD pid_ex = GetPID(pBuffer); // Aquí deberías llamar a tu función GetPID
104116
if (pid == pid_ex) {
105117
return TRUE;
106118
}
@@ -111,24 +123,26 @@ BOOL IsExcludeHWND(HWND hWnd_ex)
111123
}
112124

113125
BOOL CALLBACK PolWinProc(HWND hwnd, LPARAM lParam) {
114-
_PoL(hwnd, "Disable");
126+
_NCRP(hwnd, "Disable");
127+
_ATTRIBS_OFF(hwnd);
115128

116129
// Comprobar si la ventana es de un proceso excluido
117130
if (IsExcludeHWND(hwnd))
118131
{
119-
_PoL(hwnd, "Enable");
132+
_NCRP(hwnd, "Enable");
120133
}
121134
return TRUE;
122135
}
123136

124137
BOOL CALLBACK dPolWinProc(HWND hwnd, LPARAM lParam) {
125-
_PoL(hwnd, "Enable");
138+
_NCRP(hwnd, "Enable");
139+
_ATTRIBS_ON(hwnd);
126140
return TRUE;
127141
}
128142

129143
void CALLBACK WinEventProc(HWINEVENTHOOK hWinEventHook, DWORD event, HWND hwnd, LONG idObject, LONG idChild, DWORD dwEventThread, DWORD dwmsEventTime)
130144
{
131-
if (event == EVENT_SYSTEM_FOREGROUND && hwnd != HWNDPrev && hwnd != NULL)
145+
if (event == EVENT_SYSTEM_FOREGROUND && hwnd != HWNDPrev)
132146
{
133147
// Comprobar si la ventana actual es de un proceso excluido
134148
if (IsExcludeHWND(hwnd))
@@ -137,8 +151,8 @@ void CALLBACK WinEventProc(HWINEVENTHOOK hWinEventHook, DWORD event, HWND hwnd,
137151
}
138152

139153
// Deshabilitar la política en la ventana anterior
140-
_PoL(hwnd, "Disable");
141-
_DisableBlurBehind(hwnd);
154+
_NCRP(hwnd, "Disable");
155+
_ATTRIBS_OFF(hwnd);
142156

143157
// Actualizar HWNDPrev con el valor de la ventana actual
144158
HWNDPrev = hwnd;

0 commit comments

Comments
 (0)