Split area feature messed up then other window in background. #129414

Closed
opened 2024-10-26 17:38:30 +02:00 by MultLabs · 9 comments

System Information
Operating system: Linux-6.5.0-14-generic-x86_64-with-glibc2.35 64 Bits, X11 UI
Graphics card: NVIDIA GeForce RTX 4080/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 535.146.02

Blender Version
Broken: version: 4.3.0 Beta, branch: blender-v4.3-release, commit date: 2024-10-25 18:17, hash: 1dd6cdb1727f
Worked: 4.2

Short description of error
Split area feature messed up then other window in background. You try to split the area by dragging the corner, instead the area goes in window at background. Look at the video:

Exact steps for others to reproduce the error
I can't say that it happened in 100% cases.

**System Information** Operating system: Linux-6.5.0-14-generic-x86_64-with-glibc2.35 64 Bits, X11 UI Graphics card: NVIDIA GeForce RTX 4080/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 535.146.02 **Blender Version** Broken: version: 4.3.0 Beta, branch: blender-v4.3-release, commit date: 2024-10-25 18:17, hash: `1dd6cdb1727f` Worked: 4.2 **Short description of error** Split area feature messed up then other window in background. You try to split the area by dragging the corner, instead the area goes in window at background. Look at the video: <video src="/attachments/5451c821-23b5-4340-8226-6ef9642b1c56" title="2024-10-26_18-32-52.mp4" controls></video> **Exact steps for others to reproduce the error** I can't say that it happened in 100% cases.
MultLabs added the
Status
Needs Triage
Severity
Normal
Type
Bug
labels 2024-10-26 17:38:31 +02:00
Member

I can confirm the issue here on Linux (Gnome X11), but couldn't on Windows or macOS.

CC @Harley as the developer of the feature, and CC @ideasman42 due to their involvment in Linux windowing development.

System Information
Operating system: Linux-6.8.0-41-generic-x86_64-with-glibc2.39 64 Bits, X11 UI
Graphics card: Mesa Intel(R) Arc(tm) A750 Graphics (DG2) Intel 4.6 (Core Profile) Mesa 24.0.9-0ubuntu0.1
Blender version: 4.3.0 Beta, branch: blender-v4.3-release, commit date: 2024-10-25 18:17, hash: 1dd6cdb1727f

I can confirm the issue here on Linux (Gnome X11), but couldn't on Windows or macOS. CC @Harley as the developer of the feature, and CC @ideasman42 due to their involvment in Linux windowing development. **System Information** Operating system: Linux-6.8.0-41-generic-x86_64-with-glibc2.39 64 Bits, X11 UI Graphics card: Mesa Intel(R) Arc(tm) A750 Graphics (DG2) Intel 4.6 (Core Profile) Mesa 24.0.9-0ubuntu0.1 Blender version: 4.3.0 Beta, branch: blender-v4.3-release, commit date: 2024-10-25 18:17, hash: `1dd6cdb1727f`
Member

The video and description doesn’t detail how these multiple windows were created and in what order. And I think that is significant here. Sorry that I am away from my computer so the following is guesses from memory.

When doing operations between multiple windows it is necessary to know what window is the topmost one at the mouse position. Relative z-depth of the windows is not something we directly track, so in order for this to work flawlessly we need to ask the operating system. I don’t believe we do this for X11 so there can be times when this is incorrect.

The base behaviour, when there isn’t platform-specific code, for “what is the topmost window at this position” is to test the position against all our windows, and - when multiples- assume windows created later are on top of those created earlier, as that is more likely.

For Windows, (I think) MacOS, and (probably) Wayland, we instead call OS-supplied functions, specific to this purpose, and so always get the correct answer. Unless we get X11-specific code for this it will be possible to get bad behaviour for area interactions, drag and drop, etc if a window is above another that was created after it.

The video and description doesn’t detail how these multiple windows were created and in what order. And I think that is significant here. Sorry that I am away from my computer so the following is guesses from memory. When doing operations between multiple windows it is necessary to know what window is the **topmost** one at the mouse position. Relative z-depth of the windows is not something we directly track, so in order for this to work flawlessly we need to ask the operating system. I don’t believe we do this for X11 so there can be times when this is incorrect. The base behaviour, when there isn’t platform-specific code, for “what is the topmost window at this position” is to test the position against all our windows, and - when multiples- assume windows created later are on top of those created earlier, as that is more likely. For Windows, (I think) MacOS, and (probably) Wayland, we instead call OS-supplied functions, specific to this purpose, and so always get the correct answer. Unless we get X11-specific code for this it will be possible to get bad behaviour for area interactions, drag and drop, etc if a window is above another that was created after it.
Member

The video and description doesn’t detail how these multiple windows were created and in what order. And I think that is significant here.

When I ran my tests, I started with a single "main" window and shrunk it down, then created a new window and placed it behind the existing window. The tested.

The base behaviour, when there isn’t platform-specific code, for “what is the topmost window at this position” is to test the position against all our windows, and - when multiples- assume windows created later are on top of those created earlier, as that is more likely.

Based on my testing here, this does seem to be what's happening. Windows created later are given priority.

> The video and description doesn’t detail how these multiple windows were created and in what order. And I think that is significant here. When I ran my tests, I started with a single "main" window and shrunk it down, then created a new window and placed it behind the existing window. The tested. > The base behaviour, when there isn’t platform-specific code, for “what is the topmost window at this position” is to test the position against all our windows, and - when multiples- assume windows created later are on top of those created earlier, as that is more likely. Based on my testing here, this does seem to be what's happening. Windows created later are given priority.
Author

The video and description doesn’t detail how these multiple windows were created and in what order.

I made this two-window setup for two monitors in Blender 2.80, and haven't been changed it since that time. But it looks like the main window in the foreground creates first.

> The video and description doesn’t detail how these multiple windows were created and in what order. I made this two-window setup for two monitors in Blender 2.80, and haven't been changed it since that time. But it looks like the main window in the foreground creates first.
Julian Eisel added this to the 4.3 milestone 2024-11-05 18:38:47 +01:00

@Harley Are there any updates here?

P.S. It might be Linux specific.It is easy to reproduce on Linux (following steps from Alaska), but I didn't manage to reproduce it on macOS yet.

@Harley Are there any updates here? P.S. It might be Linux specific.It is easy to reproduce on Linux (following steps from Alaska), but I didn't manage to reproduce it on macOS yet.
Member

@Sergey

I'm back now.

Are there any updates here? ...It might be Linux specific.

It is Linux-specific. It is missing a platform-specific ghost function.

Whenever we are dealing with operations that span multiple windows (drag & drop and area maintenance stuff mostly), we need to know the source and target windows. We don't keep track of the z-depth of our windows, so when they overlap it is ambiguous.

To find out the topmost window at the current mouse pointer position we call WM_window_find_under_cursor, which in turn calls GHOST_GetWindowUnderCursor, which brings us to ghost function system->getWindowUnderCursor

The base behavior of getWindowUnderCursor (ghost\intern\GHOST_System.cc) is to just test what we think to be the mouse position against all of our windows, in reverse order, and return the first found. This means that it does return the topmost for the most common case, when a window created later is on top of one created earlier, like children on top of parents. But this will not work correctly when the windows are reversed with the older on on top.

For Mac and Windows we have specific versions of getWindowUnderCursor that asks the OS for this instead. The Windows one, for example, ignores the passed positions and instead gets the mouse position from Windows API GetCursorPos, then passes this to WindowFromPoint, which returns the topmost window at that point. The Mac version uses windowNumberAtPoint.

I don't use Linux, but as far I can tell XQueryTree is used to query windows and it looks like that those are sorted back to front, so it might not be difficult for a linux dev to add a better version of getWindowUnderCursor

@Sergey I'm back now. > Are there any updates here? ...It might be Linux specific. It is Linux-specific. It is missing a platform-specific ghost function. Whenever we are dealing with operations that span multiple windows (drag & drop and area maintenance stuff mostly), we need to know the source and target windows. We don't keep track of the z-depth of our windows, so when they overlap it is ambiguous. To find out the **topmost** window at the current mouse pointer position we call `WM_window_find_under_cursor`, which in turn calls `GHOST_GetWindowUnderCursor`, which brings us to ghost function `system->getWindowUnderCursor` The **base** behavior of `getWindowUnderCursor` (ghost\intern\GHOST_System.cc) is to just test what we think to be the mouse position against all of our windows, in reverse order, and return the first found. This means that it does return the topmost for the most common case, when a window created later is on top of one created earlier, like children on top of parents. But this will not work correctly when the windows are reversed with the older on on top. For Mac and Windows we have specific versions of `getWindowUnderCursor` that asks the OS for this instead. The Windows one, for example, ignores the passed positions and instead gets the mouse position from Windows API GetCursorPos, then passes this to `WindowFromPoint`, which returns the topmost window at that point. The Mac version uses `windowNumberAtPoint`. I don't use Linux, but as far I can tell XQueryTree is used to query windows and it looks like that those are sorted back to front, so it might not be difficult for a linux dev to add a better version of `getWindowUnderCursor`

I see, thanks for the insights.

For the X11 I've came up with the following solution:

GHOST_IWindow *GHOST_SystemX11::getWindowUnderCursor(const int32_t /*x*/, const int32_t /*y*/)
{
  /* Ignore the input coordinates, and query window under the current mouse coordinate.
   * This simplifies the query and matches the behavior of GHOST_SystemWin32::getWindowUnderCursor.
   */

  /* It appears that desktop environment (Gnome/Unity) can wrap the X window created by GHOST by
   * other X windows. presumably this is for the window decorations. We go to the deepest child
   * under the cursor, which will give X window created by GHOST_WindowX11 when the mouse is over
   * a Blender window. If the mouse is over a window of different application we might spend a bit
   * of time traversing the hierarchy, but in practice it is unlikely to cause noticeable
   * performance issues. */
  Window current_window = RootWindow(m_display, DefaultScreen(m_display));
  for (;;) {
    Window root_return;
    Window child_return;
    uint mask_return;
    int rx, ry, wx, wy;
    if (XQueryPointer(m_display,
                      current_window,
                      &root_return,
                      &child_return,
                      &rx,
                      &ry,
                      &wx,
                      &wy,
                      &mask_return) == False)
    {
      return nullptr;
    }
    if (!child_return) {
      break;
    }
    current_window = child_return;
  }

  return findGhostWindow(current_window);
}

it seems to work from quick tests, but there are a few aspects:

  • Been a while since i did X11 programming, so not sure this is the best way implementing the functionality
  • It is limited to X11, we still need to cover Wayland. It is probably not that complicated, as some of the fundamental for this functionality calls seem to be quite similar to X11.
  • It is not tested!

I don't really think the current state of the code is good enough for 4.3, and I think we either need to finish the PoC from above, or simply disable space dragging functionality from outside of the active window. The latter one might be the best, considering we're so close to the release.

I see, thanks for the insights. For the X11 I've came up with the following solution: ``` GHOST_IWindow *GHOST_SystemX11::getWindowUnderCursor(const int32_t /*x*/, const int32_t /*y*/) { /* Ignore the input coordinates, and query window under the current mouse coordinate. * This simplifies the query and matches the behavior of GHOST_SystemWin32::getWindowUnderCursor. */ /* It appears that desktop environment (Gnome/Unity) can wrap the X window created by GHOST by * other X windows. presumably this is for the window decorations. We go to the deepest child * under the cursor, which will give X window created by GHOST_WindowX11 when the mouse is over * a Blender window. If the mouse is over a window of different application we might spend a bit * of time traversing the hierarchy, but in practice it is unlikely to cause noticeable * performance issues. */ Window current_window = RootWindow(m_display, DefaultScreen(m_display)); for (;;) { Window root_return; Window child_return; uint mask_return; int rx, ry, wx, wy; if (XQueryPointer(m_display, current_window, &root_return, &child_return, &rx, &ry, &wx, &wy, &mask_return) == False) { return nullptr; } if (!child_return) { break; } current_window = child_return; } return findGhostWindow(current_window); } ``` it seems to work from quick tests, but there are a few aspects: - Been a while since i did X11 programming, so not sure this is the best way implementing the functionality - It is limited to X11, we still need to cover Wayland. It is probably not that complicated, as some of the fundamental for this functionality calls seem to be quite similar to X11. - It is not tested! I don't really think the current state of the code is good enough for 4.3, and I think we either need to finish the PoC from above, or simply disable space dragging functionality from outside of the active window. The latter one might be the best, considering we're so close to the release.
Member

@Sergey

Thanks for the help.

or simply disable space dragging functionality from outside of the active window. The latter one might be the best, considering we're so close to the release.

The problem with completely disabling this for Linux outside of the active window is that it would then not work for the simple case of dragging between multiple windows that do not overlap. I think I can check (only for Linux) for multiple windows matching and in that case use the active one.

But hoping to add you as the reviewer since I don't run Linux.

@Sergey Thanks for the help. > or simply disable space dragging functionality from outside of the active window. The latter one might be the best, considering we're so close to the release. The problem with completely disabling this for Linux outside of the active window is that it would then not work for the simple case of dragging between multiple windows that do not overlap. I think I can check (only for Linux) for multiple windows matching and in that case use the active one. But hoping to add you as the reviewer since I don't run Linux.
Harley Acheson self-assigned this 2024-11-13 21:51:16 +01:00
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2024-11-14 22:31:54 +01:00
Author

Works now, but this #129415 still is broken.

Works now, but this https://projects.blender.org/blender/blender/issues/129415 still is broken.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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
4 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#129414
No description provided.