leon-thomm / Ryven

Flow-based visual scripting for Python
https://ryven.org
MIT License
3.77k stars 439 forks source link

Unnecessary recalculation when the windows looses focus #106

Open sphh opened 2 years ago

sphh commented 2 years ago

I just noticed, that Ryven recalculates the project, whenever the window looses the focus:

  1. Open a project in Ryven.
  2. Activate another window.
  3. The project is recalculated.

The project is even recalculated, when pressing the window close button.

Is this an intended behaviour or a side-effect of me having activated the window focus mode sloppy on Linux?

leon-thomm commented 2 years ago

What exactly do you mean by recalculating the project? (Serialization? Rendering? Flow updates?)

sphh commented 2 years ago

I mean: Flow updates – The update_event() of all nodes are called.

leon-thomm commented 2 years ago

The update events must have a unique source, which is probably the input of a node. Some dtype widgets (the ones with a QLineEdit) cause updates on editingFinished, which is emitted also when losing focus. Only this is what I can think of right now, in which case, yes, this is intended but isn't particular to focusing on another application, but originates from editing an input and then leaving it.

sphh commented 2 years ago

Yes, I use dtype widgets!

And if we used the textEdited signal, update_event() would be called on every edit action and with returnPressed the update_event() is only called, if the return key is pressed, but not when the user moves the cursor with the mouse or the tab key; right?

Any chance to call update_event() only if the widget looses focus and the contents has changed?

leon-thomm commented 2 years ago

And if we used the textEdited signal, update_event() would be called on every edit action and with returnPressed the update_event() is only called, if the return key is pressed, but not when the user moves the cursor with the mouse or the tab key; right?

yep

Any chance to call update_event() only if the widget looses focus and the contents has changed?

Should be possible, yes. I'll try. Pressing return should IMO still be possible for forcing updates, but I can make the update on unfocus conditional, I think.

sphh commented 2 years ago

Pressing return should IMO still be possible for forcing updates, but I can make the update on unfocus conditional, I think.

Sounds like a good plan!!