Maniphest T52999

invoke_props_dialog() window changes position on redraw if the window has sufficient vertical height
Closed, Resolved

Assigned To
Bastien Montagne (mont29)
Authored By
Ryan Guy (rlguy)
Oct 5 2017, 3:55 AM
Tags
  • BF Blender
Subscribers
Bastien Montagne (mont29)
Ryan Guy (rlguy)
Sergey Sharybin (sergey)
Vuk Gardašević (lijenstina)

Description

System Information
Operating system: Windows 7
Graphics: Intel HD4400

Blender Version
Broken: 2.79 5bd8ac9

Short description of error
After repositioning a dialog window, when redrawn, the window will change location. After a few repositions (around 4), the window will stay in place after redraws as expected. The number of repetitions until the dialog is stabilized seems to depend on the height of the dialog window with more repetitions required for a taller windows.

Exact steps for others to reproduce the error

Script:

import bpy

class MyDialogOperator(bpy.types.Operator):
    bl_idname = "my_test.my_dialog_operator"
    bl_label = "My Dialog Operator"
    
    toggle = bpy.props.BoolProperty()

    def check(self, context):
        return True
    
    def draw(self, context):
        self.layout.prop(self, "toggle", text="Toggle to redraw")
        for i in range(20):
            self.layout.label(str(i))
    
    def execute(self, context):
        return {'FINISHED'}

    def invoke(self, context, event):
        return context.window_manager.invoke_props_dialog(self)
    
bpy.utils.register_class(MyDialogOperator)
bpy.ops.my_test.my_dialog_operator('INVOKE_DEFAULT')
  1. Open Blender and run script (Dialog opens)
  1. REPEAT:

    a) Reposition window to center of screen

    b) Click 'Toggle to redraw ' checkbox (Dialog window changes location)

Revisions and Commits

rB Blender

Related Objects

Mentioned In
T60608: Properties dialogs created by addons via wm.invoke_props_dialog() jump around vertically.
Mentioned Here
rB5bd8ac9abfa2: Update release cycle to 'release'.

Event Timeline

Ryan Guy (rlguy) created this task.Oct 5 2017, 3:55 AM
Sergey Sharybin (sergey) lowered the priority of this task from 90 to 30.Oct 5 2017, 12:17 PM
Sergey Sharybin (sergey) added a subscriber: Sergey Sharybin (sergey).

I can not reproduce the issue on Linux, so either initial positions of popup are different, or something is platform-specific. Please describe steps as clear as possible, maybe with some screenshots or so.

Vuk Gardašević (lijenstina) added a subscriber: Vuk Gardašević (lijenstina).EditedOct 5 2017, 2:05 PM

When redraw code is used

def check(self, context):
    return True

the Operator pop-up can change it's location (jump around on the screen) depending on the cursor's position and height of the pop-up (for instance after tweaking some values in properties).

For instance that can happen with Discombobulator from Add Mesh: Extra Objects

Ryan Guy (rlguy) added a comment.Oct 5 2017, 7:01 PM

Thanks for the quick responses. I am able to reproduce this on Windows 10 (GTX 1070 8GB) with the same build, and also with using the 'Discombobulator' menu. I have attached a screencast of the issue:

Is there a way to prevent the pop-up from jumping around when the check() redraw is used? I would like to have a pop-up that redraws menu items dependant on which options are selected and it could be distracting to the user if the pop-up jumps locations.

Sergey Sharybin (sergey) assigned this task to Bastien Montagne (mont29).Oct 11 2017, 3:33 PM
Sergey Sharybin (sergey) raised the priority of this task from 30 to 50.
Sergey Sharybin (sergey) added a subscriber: Bastien Montagne (mont29).

Now i see the problem. The trick was to make popup to "stick" to one of the window corners. Here is a .blend file i've used

.

@Bastien Montagne (mont29), is this area something you're comfortable with? :)

Bastien Montagne (mont29) added a comment.Oct 12 2017, 12:36 PM

Not really comfortable with our UI popup code no… this code is a bit of a maze, with lots of indirect/callbacks stuff that makes it difficult to track. :|

Anyway, root of the issue is that floating UI_BLOCK_BOUNDS_POPUP_MOUSE and UI_BLOCK_BOUNDS_POPUP_MENU blocks use the mouse position as base to decide where they popup on screen. That initial mouse position is stored, and updated when you drag the popup around. BUT! Initial position of the popup may be adjusted to keep it fully inside main window - and this is where the can of worms opens.

Will try to figure out a way around that mess. :/

Bastien Montagne (mont29) added a comment.Oct 12 2017, 2:50 PM

Fix incoming.

Note that panel will still jump in case user dragged it partially out of view - we could prevent that, but imho it's better to keep that behavior, since redraw can generate a popup of different size, which could end up with a totally out-of-view one...

Bastien Montagne (mont29) changed the task status from Unknown Status to Resolved by committing rB3b4f6996a8fd: Fix T52999: floating (popup) panels/menus could jump around screen in some….Oct 12 2017, 2:51 PM
Bastien Montagne (mont29) added a commit: rB3b4f6996a8fd: Fix T52999: floating (popup) panels/menus could jump around screen in some….