Post Aql2TP6bsEZXGlqqCu by blp@framapiaf.org
(DIR) More posts by blp@framapiaf.org
(DIR) Post #AqkOF5e9QeGahK9xxo by foone@digipres.club
2025-02-03T16:39:55Z
1 likes, 0 repeats
PSA because every couple years I run into programmers who don't understand this:WINDOW COORDINATES CAN BE NEGATIVE AND VALID ON WINDOWS
(DIR) Post #AqkOJSCXVsCfoAKF3A by foone@digipres.club
2025-02-03T16:40:41Z
1 likes, 0 repeats
set up a computer with two monitors, make the one on the right be the primary.(0,0) is at the top-left of the primary monitor, the right one. So the coordinates of windows on the left monitor will be negative.
(DIR) Post #AqkOWalmy0429D4t0K by foone@digipres.club
2025-02-03T16:43:05Z
0 likes, 0 repeats
I keep running into software written by people who don't understand this. SetCursor-type APIs that won't accept negative numbersprograms that save their position between runs, but don't accept negative numbers (so if you close and reopen it on the left monitor, it moves to the right monitor)screen capture APIs that can't capture windows on the left screen because they're "invalid"
(DIR) Post #AqkOkJ63TJKXOD64bQ by Ronflaix@mastodon.gamedev.place
2025-02-03T16:45:25Z
0 likes, 0 repeats
@foone Wasn't there some weird Win32 event/method that put them faaaar away in the top-left negative quadrant to hide the windows without hiding them or did I hallucinate that?
(DIR) Post #AqkOvvES1drEqkYweO by foone@digipres.club
2025-02-03T16:47:36Z
0 likes, 0 repeats
@Ronflaix Yeah, I believe that was how they got minimized on Windows 95, which could break in windows 98 because you could now have multiple monitors and make that coordinate visible
(DIR) Post #AqkP49Rt3HddG6lsOm by foone@digipres.club
2025-02-03T16:49:06Z
0 likes, 0 repeats
Pillow's ImageGrab is so subtly broken that it's frankly amazing. Besides the weird DPI problems I'm having, it lets you write code that will work if you run it on a system without a left-of-primary monitor, and break if it does
(DIR) Post #AqkPG2Or5M7qs81MUi by foone@digipres.club
2025-02-03T16:51:13Z
0 likes, 0 repeats
Here's some code:x,y,w,h=win32gui.GetClientRect(hwnd)x,y=win32gui.ClientToScreen(hwnd, (x,y))rect=(x,y,x+w,y+h)im=ImageGrab.grab(rect,all_screens=True)This gets the size of a window, figures out where on the screens it is, converts that to a PIL style rectangle, then tells PIL to screenshot it. And this should work fine.
(DIR) Post #AqkPKjSoutCjah78Zk by foone@digipres.club
2025-02-03T16:52:07Z
0 likes, 0 repeats
BUT if you have a monitor left of your active one, it turns out this will screenshot entirely the wrong place.It's because Pillow doesn't screenshot just the area you select, it screenshots all the screens as one big image, and then crops that.
(DIR) Post #AqkPPiclSvlGR18wTY by foone@digipres.club
2025-02-03T16:53:01Z
0 likes, 0 repeats
meaning it uses X-style "top-left monitor has (0,0) in the top-left" coordinates, even on windows WHICH DOESN'T USE THAT COORDINATE SYSTEM
(DIR) Post #AqkPbs1cL63p49YvFw by foone@digipres.club
2025-02-03T16:55:15Z
0 likes, 0 repeats
Windows has only been Like This for 27 years, I'm amazed how often this causes bugs.
(DIR) Post #AqkPiQf0Tko4Dt771E by Ronflaix@mastodon.gamedev.place
2025-02-03T16:56:18Z
0 likes, 0 repeats
@foone Amazing. Did they ever fix it or are we that close from seeing windows just moving around because we've got big ass-screens now?
(DIR) Post #AqkPmBiFzmqp1RQUvw by foone@digipres.club
2025-02-03T16:56:42Z
0 likes, 0 repeats
@Ronflaix not sure.
(DIR) Post #AqkPv931H2ELMYPPqi by foone@digipres.club
2025-02-03T16:58:39Z
0 likes, 0 repeats
@lily @Ronflaix https://devblogs.microsoft.com/oldnewthing/20041028-00/?p=37453
(DIR) Post #AqkQ8VOFW5CAQAi3tY by foone@digipres.club
2025-02-03T17:01:01Z
0 likes, 0 repeats
actually I may be wrong about Pillow doing this, I just got it to work and I'm not 100% way. I think I'm seeing the DPI fuck it up
(DIR) Post #AqkTvsNn7QjZmdjFhI by lp0_on_fire@social.linux.pizza
2025-02-03T17:43:31Z
0 likes, 0 repeats
@foone. they can be negative anyway, whichever windowing system is in use. They're just not going to be (fully) within the display area.The really fun™ problems are when you've swapped your differently-sized monitors and some program opens a window at a now completely off-screen saved position.
(DIR) Post #AqkUfZHMThuTr5VcUi by tursilion@furries.club
2025-02-03T17:51:50Z
0 likes, 0 repeats
@foone It gets better than that, the coordinate system changed in Windows 8. I have some code that generates a mosaic backdrop image that I needed to add Windows 8 detection to ensure it worked on both pre-and-post versions.
(DIR) Post #AqkWf2IRJ4EtTBt4SG by nicoduck@chaos.social
2025-02-03T18:14:09Z
0 likes, 0 repeats
@foone aah that's why some software will never open on a secondary left monitor after closing 🤦♂️😂
(DIR) Post #AqkfA9kQS46VBrKNpw by wiredfool@fosstodon.org
2025-02-03T19:49:22Z
0 likes, 0 repeats
@foone Entirely possible. There have been some issues with multiple monitors and Dpi support. Windows has always been a bit of a second class support, as the core devs are mainly not windows people. It’s only recently that we’ve built the shipping binaries on CI and not relied on cgohilke’s build farm.
(DIR) Post #AqkmRsWzttdEgZRcki by TimWardCam@c.im
2025-02-03T21:10:51Z
0 likes, 0 repeats
@foone It's a long time since I've done any Windows UI programming but IIRC there are around 17 coordinate systems, several of which have the entire Y axis going backwards.
(DIR) Post #Aql2TP6bsEZXGlqqCu by blp@framapiaf.org
2025-02-04T00:10:25Z
0 likes, 0 repeats
@foone What blew my mind several years ago was running into the Cairo API, where all the coordinates are floating-point. When I learned programming, only a lunatic would have considered using floating point for anything intended as a low-level screen drawing library. And, these days, it's fast enough and it just doesn't matter!