Fix #109886: Win32 AutoFocus Between Main Windows #109946

Merged
Harley Acheson merged 1 commits from Harley/blender:AutoFocusMain into main 2023-07-11 21:13:57 +02:00
Member

Allow auto-focusing between multiple parent (main) windows when they
are immediately adjacent.


Issue #109886 describes a lack of auto-focus between main windows when they are full-screen on multiple adjacent monitors.

But this issue isn't really related to windows being full-screen or when on multiple monitors. It is most easily replicated like this:

  • Start Blender and resize its window until it is smaller than half the width of your monitor.
  • From the top menus select Window / New Main Window
  • Move the two windows until they are next to each other.

If they are closer than about 20 pixels they won't auto-focus.

We allow auto-focusing between multiple main (parent) windows as long as they don't overlap. Unfortunately our test for overlapping is a bit sus. Since Vista the Windows API call GetWindowRect now includes the area occupied by the drop shadow that is beyond the window bounds. Because we are using a rectangle larger than the window the two windows can be quite far apart and test as overlapping.

This PR just uses a different Windows API call that returns the actual window bounds instead.

Allow auto-focusing between multiple parent (main) windows when they are immediately adjacent. --- Issue #109886 describes a lack of auto-focus between main windows when they are full-screen on multiple adjacent monitors. But this issue isn't really related to windows being full-screen or when on multiple monitors. It is most easily replicated like this: * Start Blender and resize its window until it is _smaller than half the width of your monitor_. * From the top menus select **Window / New Main Window** * Move the two windows until they are next to each other. If they are closer than about 20 pixels they won't auto-focus. We allow auto-focusing between multiple main (parent) windows as long as they don't overlap. Unfortunately our test for overlapping is a bit sus. Since Vista the Windows API call GetWindowRect now includes the area occupied by the **drop shadow** that is beyond the window bounds. Because we are using a rectangle larger than the window the two windows can be quite far apart and test as overlapping. This PR just uses a different Windows API call that returns the actual window bounds instead.
Harley Acheson added 1 commit 2023-07-11 01:18:25 +02:00
bdc44e4bee Fix #109886: Win32 AutoFocus Between Main Windows
Allow auto-focusing between multiple parent (main) windows when they
are immediately adjacent.
Harley Acheson added this to the Platforms, Builds Tests & Devices project 2023-07-11 01:19:28 +02:00
Harley Acheson requested review from Ray molenkamp 2023-07-11 01:19:35 +02:00
Member

I can't test this as i'm single monitor only, but can you validate monitors with different DPI's work as expected?

https://stackoverflow.com/questions/49002910/why-does-dwmgetwindowattribute-with-dwmwa-extended-frame-bounds-behave-unexpecte

seems to imply some dpi magic may be at play, depending on if we opted in to be dpi aware or not.

I can't test this as i'm single monitor only, but can you validate monitors with different DPI's work as expected? https://stackoverflow.com/questions/49002910/why-does-dwmgetwindowattribute-with-dwmwa-extended-frame-bounds-behave-unexpecte seems to imply some dpi magic may be at play, depending on if we opted in to be dpi aware or not.
Author
Member

@LazyDodo - can you validate monitors with different DPI's work as expected?

They do. I was also expecting some DPI nonsense, so put two of my monitors in different scales (100% and 125%) and tested two main windows in various locations. They worked as expected when entirely on each monitor and in all variations of having some or all of each on each monitor.

I think the warnings about DPI are related to similar warnings about the function not working correctly if the window is not visible and/or not shown at least once, which doesn't apply here. So it doesn't (like many of their functions) have the ability to guess the size of non-client areas before the window is drawn. I have read (although not confirmed) that this function is used by PrintScreen since Vista to capture windows without the shadow space.

> @LazyDodo - can you validate monitors with different DPI's work as expected? They do. I was also expecting some DPI nonsense, so put two of my monitors in different scales (100% and 125%) and tested two main windows in various locations. They worked as expected when entirely on each monitor and in all variations of having some or all of each on each monitor. I think the warnings about DPI are related to similar warnings about the function not working correctly if the window is not visible and/or not shown at least once, which doesn't apply here. So it doesn't (like many of their functions) have the ability to guess the size of non-client areas before the window is drawn. I have read (although not confirmed) that this function is used by PrintScreen since Vista to capture windows without the shadow space.
Ray molenkamp approved these changes 2023-07-11 19:31:35 +02:00
Ray molenkamp left a comment
Member

allright then!

allright then!
Author
Member

Will be merged without further review. Is own code, Windows-only, and has no change of functionality besides fixing this bug report.

Will be merged without further review. Is own code, Windows-only, and has no change of functionality besides fixing this bug report.
Harley Acheson merged commit 30d44548e3 into main 2023-07-11 21:13:57 +02:00
Harley Acheson deleted branch AutoFocusMain 2023-07-11 21:14:01 +02:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#109946
No description provided.