WIP: UI: Save Temp Window Sizes & Positions #104727

Draft
Harley Acheson wants to merge 2 commits from Harley/blender:WindowPosSize into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Member

Allow temporary windows (like File Browser, Preferences, Render,
Drivers, Info) to open at their last positions and sizes.


UserDef gets a new kind of struct to contain a temp window's position and size. A new WM_window_open_temp takes a pointer to one of these as a parameter and automatically saves and restores on close and open.

Positions are saved in unscaled values (as if the UI scale is 1.0), using the DPI scale of the parent window. Using unscaled values means that if you increase the UI scale the temp window sizes are suitably scaled as well. Using the DPI of the parent is required to position them correctly in complex situations like having multiple monitors that differ in OS scale.

Note this currently only saves and restores the size and position of the Preferences and File Browser windows. But this design could easily work for other windows after it is confirmed (or fixed) to work on Mac and Linux.

Allow temporary windows (like File Browser, Preferences, Render, Drivers, Info) to open at their last positions and sizes. --- UserDef gets a new kind of struct to contain a temp window's position and size. A new `WM_window_open_temp` takes a pointer to one of these as a parameter and automatically saves and restores on close and open. Positions are saved in unscaled values (as if the UI scale is 1.0), using the DPI scale of the parent window. Using unscaled values means that if you increase the UI scale the temp window sizes are suitably scaled as well. Using the DPI of the parent is required to position them correctly in complex situations like having multiple monitors that differ in OS scale. Note this **currently only saves and restores the size and position of the Preferences and File Browser windows**. But this design could easily work for other windows after it is confirmed (or fixed) to work on Mac and Linux.
Harley Acheson force-pushed WindowPosSize from 9ef8eac91d to 82675a6d04 2023-02-16 04:03:16 +01:00 Compare
Harley Acheson force-pushed WindowPosSize from 82675a6d04 to f2e4f60631 2023-12-15 03:23:56 +01:00 Compare
Harley Acheson added this to the User Interface project 2023-12-15 03:25:56 +01:00
Author
Member

@rajveermalviya

Is any way you can take a look at this? This should just automatically save and restore the last sizes and positions of the Preferences window. But the last I heard some of these are incorrect on Mac with Retina displays.

We do measuring a bit wrong on high-dpi though, so this will just come down to a bad or missing use of GHOST_GetNativePixelSize

@rajveermalviya Is any way you can take a look at this? This should just automatically save and restore the last sizes and positions of the Preferences window. But the last I heard some of these are incorrect on Mac with Retina displays. We do measuring a bit wrong on high-dpi though, so this will just come down to a bad or missing use of GHOST_GetNativePixelSize
Contributor

I tried this impl on my macbook and found that window positions and window sizes are being preserved correctly on laptop display.

But (for me) absolute positioning in general is broken on extended displays. I even tested with current main but that didn't change anything. Is there a bug already for it? (couldn't find one)

I tried this impl on my macbook and found that window positions and window sizes are being preserved correctly on laptop display. But (for me) absolute positioning in general is broken on extended displays. I even tested with current `main` but that didn't change anything. Is there a bug already for it? (couldn't find one)
Author
Member

I tried this impl on my macbook and found that window positions and window sizes are being preserved correctly on laptop display.

Oh so it works to set and restore the size and position on the built-in monitor. Those are all Retina right, so high-dpi? That would be a good sign that the PR is probably doing everything correctly.

But (for me) absolute positioning in general is broken on extended displays. I even tested with current main but that didn't change anything.

So you are saying that positioning on multiple displays is incorrect in main? I'm not surprised as that seems to be incomplete on Mac.

On Windows I can start with defaults. Then choose Window/ New Window and move the resulting window anywhere to any of my monitors. I can do this to make and arrangement of windows all over the place. Then I can select File / Defaults / Save Startup File. I can close and launch Blender again - everything will be back to where they were to the pixel.

If this isn't working on Mac we might have to identify exactly which parts aren't working correctly. Its not that hard to figure out to be honest. Window creation is all done in wm_window.c, and by examining what happens when windows are made we might find that we are missing some ghost functions. Like wm_get_desktopsize could be getting the wrong values.

Is there a bug already for it? (couldn't find one)

I doubt it. But knowing what works on Windows, it would make sense to create a bug report for the missing/broken behavior on Mac.

> I tried this impl on my macbook and found that window positions and window sizes are being preserved correctly on laptop display. Oh so it works to set and restore the size and position on the built-in monitor. Those are all Retina right, so high-dpi? That would be a good sign that the PR is probably doing everything correctly. > But (for me) absolute positioning in general is broken on extended displays. I even tested with current `main` but that didn't change anything. So you are saying that positioning on multiple displays is incorrect in main? I'm not surprised as that seems to be incomplete on Mac. On Windows I can start with defaults. Then choose Window/ New Window and move the resulting window anywhere to any of my monitors. I can do this to make and arrangement of windows all over the place. Then I can select File / Defaults / Save Startup File. I can close and launch Blender again - everything will be back to where they were to the pixel. If this isn't working on Mac we might have to identify exactly which parts aren't working correctly. Its not that hard to figure out to be honest. Window creation is all done in wm_window.c, and by examining what happens when windows are made we might find that we are missing some ghost functions. Like wm_get_desktopsize could be getting the wrong values. > Is there a bug already for it? (couldn't find one) I doubt it. But knowing what works on Windows, it would make sense to create a bug report for the missing/broken behavior on Mac.
Harley Acheson added 1 commit 2023-12-30 21:03:35 +01:00
This pull request has changes conflicting with the target branch.
  • source/blender/windowmanager/intern/wm_window.cc

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u WindowPosSize:Harley-WindowPosSize
git checkout Harley-WindowPosSize
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
Interest: X11
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 project
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#104727
No description provided.