Wrong width returned from bpy.types.Window.width (depending on native pixel size) #84204
Labels
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
5 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#84204
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
System Information
OS: macOS Mojave (10.14.6)
Graphic card: Radeon Pro 450 2GB
Blender Version
Broken version: 2.91.0
Description of error
bpy.types.Window.width does not return correct value in my environment.
I tried to get window size of Blender via bpy.context.window_manager.windows- [x].width.
But the returned value differs from the actual window width (Actual window width: 2880, Returned value: 1680).
Also, I found that bpy.context.window_manager.windows- [x].x also returned invalid value.
Other related values such as region.width, area.width seems fine in my environment.
Added subscriber: @nutti
Added subscriber: @jenkm
For me, it returns
1680
and the real width is3360
, which can be called a correct value since there are twice as many pixels on the Retina.But the issue is that you can't know if it's Retina or regular screen, in the Python I mean. In C it's
GHOST_GetNativePixelSize()
and the value is corrected when it is necessary.Thanks @jenkm !
Yes, that's right. Is there any way to correct those values from Python?
I think that
GHOST_GetNativePixelSize
does not expose API to Python.Added subscribers: @JulianEisel, @lichtwerk
Changed status from 'Needs Triage' to: 'Needs Developer To Reproduce'
A bit on shaky ground [also cannot test here], but couldnt get native pixel size be considered when getting this through RNA?
With a function defined through
RNA_def_property_int_funcs
?CC @JulianEisel
Wrong width returned from bpy.types.Window.widthto Wrong width returned from bpy.types.Window.width (depending on native pixel size)Changing the property to respect the native pixel size would be an API compatibility breaking change, I don't think we should do this. We could expose the native pixel size, or give functions to convert dimensions and coordinates from and to real pixel values.
Either way, the property description should state if it's not in real pixels and if the pixel size needs to be multiplied.
Not sure we can break what's already broken. We could expose the native_pixel_size but I don't see the point, you need to always multiply/divide by it. The cursor coordinates are already multiplied by it, you can have two monitors with different dpi, and so on.
Moreover this is not an API issue. These native window sizes in virtual pixels are only needed when creating a window in GHOST/Cocoa. There are already many problems/inconveniences with the need for this conversion. Some recent ones I've encountered: D9837 D9976 D9836.
There is also the issue that we have the cursor coordinates in two-pixel increments on the Retina. And when I tried to fix this the first thing I came across was exactly these window sizes not matching the cursor coordinate.
Another example. In
WM_window_open()
, we usenative_pixel_size
to correct the window size. But we pass different values to this function. In case ofarea_dupli
it's the "area" size, and it's works correctly. But forwindow_new
it's "win" size which does not need to be adjusted, so we have a new window half as small as it should be.This is still an issue when we try to get the maximal possible size of area when the area gets resized and we draw something from Python. (where it's assumed the maximal size will be that one of window)