bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#51404: Support system dark mode on Windows 10


From: Vince Salvino
Subject: bug#51404: Support system dark mode on Windows 10
Date: Sat, 29 Jan 2022 20:27:48 +0000

Thanks for the review. Attached is the revised patch, minus one thing 
specifically:

> I see where you add windows to the list, but I don't see where you remove 
> deleted windows from the list.  Does that mean the list will always grow 
> indefinitely through an Emacs session, even if windows are deleted?

I also had this concern but found it a bit sticky. I can't quite find a way to 
know if a HWND is destroyed. Windows seems to keep the HWNDs in memory, and 
even reuses them if a window is destroyed and new one is created. The win32 API 
seems to be designed around this behavior as calling functions with a HWND that 
is destroyed or that is not owned by the program will not have any adverse 
effects.

I experimented with WM_EMACS_DESTROYWINDOW but that seems to only be triggered 
on the titlebar destroy, not the other "windows" such as scrollbars, menu, etc.

To answer your question, yes the current implementation will grow indefinitely. 
Practically speaking the memory overhead is quite small though - as a marathon 
emacs session creating and destroying thousands of frames repeatedly might add 
up to few kilobytes memory overhead on supported Win 10 systems (each entry is 
16 bytes). It's definitely sloppy programming, but I will have to continue to 
learn more about win32 to figure out the solution, given enough free time in 
the future.

A few items of note:
* https://stackoverflow.com/questions/2344233/validate-hwnd-using-win32-api
* I'm still digging through the code to figure out if emacs has a parent/child 
relationship for HWNDs, in which case this might be relevant (especially 
EnumChildWindows to loop through children and purge them from the list): 
https://docs.microsoft.com/en-us/windows/win32/winmsg/using-windows


Vince Salvino

Attachment: 0002-Support-MS-Windows-light-dark-mode-theme-change-duri.patch
Description: 0002-Support-MS-Windows-light-dark-mode-theme-change-duri.patch


reply via email to

[Prev in Thread] Current Thread [Next in Thread]