Page MenuHome

T88308 Potential Fix
Changes PlannedPublic

Authored by AJP (astronotter) on Jun 26 2021, 2:18 AM.

Details

Summary

Allow move's modal operator to accept and handle scroll events.

Diff Detail

Repository
rB Blender

Event Timeline

AJP (astronotter) requested review of this revision.Jun 26 2021, 2:18 AM
AJP (astronotter) created this revision.
source/blender/editors/space_view3d/view3d_edit.c
1878

Is it necessary to modify poll here? The purpose of poll is to filter out events, and iirc ED_operator_region_view3d_active is just checking if View3D is the active region.

source/blender/editors/space_view3d/view3d_edit.c
1773–1777

It may be appropriate to add null checks for ot and props_ptr. If you referenced code which didn't have these checks than it might be standard to assume these are never null (I'm not familiar enough with operator code to assert either way).

Removed change to poll callback, seems to work with original!

AJP (astronotter) planned changes to this revision.Jun 26 2021, 2:47 AM
AJP (astronotter) added inline comments.
source/blender/editors/space_view3d/view3d_edit.c
1878

Huh... it seems to work with it switched back to the original so I guess not! Originally I wasn't getting scroll events at all until I switched that, but I think I also tried using apply instead of modal at first so maybe that's why :)

source/blender/editors/space_view3d/view3d_edit.c
1773–1777

Yeah I based it off of the block at line 349 editors/interface/interface_anim.c but it does look like WM_operatortype_find can return NULL at least theoretically, so I'm not sure.

You may be able to use something in WM_keymap.h to check if scroll is actually mapped to zoom before running it. I say "may" because this is really a guess on my part. The function that stood out to me was WM_keymap_ensure but there might be something more appropriate if you poke around.

AJP (astronotter) added a comment.EditedJun 27 2021, 12:57 AM

@Nicholas Rishel (nicholas_rishel) Hmm I see what you mean. That also doesn't help much if the scroll wheel is associated with another function entirely. I guess the most ideal solution would be to pass the event back to the WM to be handled by the next handler somehow? I would have thought returning with the flag OPERATOR_PASS_THROUGH would allow this but it doesn't seem to work.

Edit: I've done a bit more digging on this front and it seems that if I add the shift key modifier to the keymap for zoom in and out, then exiting early with OPERATOR_PASS_THROUGH when a scroll event is detected solves the issue.

Just a recap of what we discussed in chat for posterity:

Operator passthrough is not an option because it requires every variant of scroll + (alt | shift | ctrl) to be mapped to zoom for every variant of modal middle mouse + (alt | shift | ctrl). This likely also kills the alternative, add the idea of zoom to every operator variant of modal middle mouse + (alt | shift | ctrl), which in practice can be any modal operator.

I'm increasingly of the opinion there isn't a good way forward, it's unfortunately a problem that falls out from a hardware quirk running against the nature of modal input.