Track windows cross-platform lazarus / 23-Operating Systems ---------------------------------------------------------------------- LemonParty · 2026-04-08 16:03 Hello. I want to know if there is a cross platform way (Windows, Linux and probably macOS) to track window position and size. I have a window handle and I want to know when this window changes position or resizes. ---------------------------------------------------------------------- dsiders · 2026-04-08 17:43 Quote from: LemonParty on April 08, 2026, 06:03:55 pmHello. I want to know if there is a cross platform way (Windows, Linux and probably macOS) to track window position and size. I have a window handle and I want to know when this window changes position or resizes. OnResize and OnChangeBounds. https://lazarus-ccr.sourceforge.io/docs/lcl/forms/tform.html ---------------------------------------------------------------------- LemonParty · 2026-04-08 19:57 No, I mean track positions and sizes of windows of any applications, include not created by Lazarus. ---------------------------------------------------------------------- dsiders · 2026-04-08 20:32 Quote from: LemonParty on April 08, 2026, 09:57:19 pmNo, I mean track positions and sizes of windows of any applications, include not created by Lazarus. That is decidedly platform-specific... and in the case of QT not available at all (to my knowledge). ---------------------------------------------------------------------- 440bx · 2026-04-08 20:33 Quote from: LemonParty on April 08, 2026, 09:57:19 pmNo, I mean track positions and sizes of windows of any applications, include not created by Lazarus. before anything, I don't have a cross platform solution. In Windows, it's not hard to do but, it could potentially be a CPU hog.  The solution is to enumerate the windows every "n" milliseconds and for every top level window get its window rectangle (not the client's.)  Compare that value (which is the current) with a value that was previously saved.  Anytime the window rectangle is different it means that either the position, the size or both changed. The amount of CPU used will depend on how often you decide to enumerate the windows. if you enumerate no more often than every 20ms, the CPU usage should likely be acceptable. HTH. ---------------------------------------------------------------------- Xenno · 2026-04-09 12:57 There is GetWindowRect function in LCLIntf, but it's said not working on non-Windows. ---------------------------------------------------------------------- PascalDragon · 2026-04-10 05:21 Quote from: LemonParty on April 08, 2026, 06:03:55 pmI want to know if there is a cross platform way (Windows, Linux and probably macOS) to track window position and size. I have a window handle and I want to know when this window changes position or resizes. On Linux with Wayland that is simply not possible as Wayland does not support such functionality by design (even for one's own windows!). ---------------------------------------------------------------------- LemonParty · 2026-04-10 15:37 Quote from: PascalDragon on April 10, 2026, 07:21:06 amQuote from: LemonParty on April 08, 2026, 06:03:55 pmI want to know if there is a cross platform way (Windows, Linux and probably macOS) to track window position and size. I have a window handle and I want to know when this window changes position or resizes. On Linux with Wayland that is simply not possible as Wayland does not support such functionality by design (even for one's own windows!). Linux users advertise Linux as a home OS. But how anyone suppose to use it if basic things like check window position is not supported. Why developers of Wayland don't allow this? ---------------------------------------------------------------------- dsiders · 2026-04-10 17:43 Quote from: LemonParty on April 10, 2026, 05:37:47 pmQuote from: PascalDragon on April 10, 2026, 07:21:06 amQuote from: LemonParty on April 08, 2026, 06:03:55 pmI want to know if there is a cross platform way (Windows, Linux and probably macOS) to track window position and size. I have a window handle and I want to know when this window changes position or resizes. On Linux with Wayland that is simply not possible as Wayland does not support such functionality by design (even for one's own windows!). Linux users advertise Linux as a home OS. But how anyone suppose to use it if basic things like check window position is not supported. Why developers of Wayland don't allow this? Linux doesn;t have one window manager, desktop, and API... it has many. And they're all different. So, Linux has "freedom of choice"'d itself into relative desktop obscurity. It has tools like wmctrl and xwininfo to do those things... but they're not integrated into QT or GTK for example. Because that would require them to support the mechanisms for every window manager. Wayland is just a brain-dead specification. And by resisting such basic functionality they demonstrate why they are both arrogant and ignorant. But at least Linux users don't have to endure advertisements in their start menu.