[Solved] Conditional Delayed Command

I’m trying in a function binded to mouse to make an Exec command executed after a certain delay and only if something else is not happened (a Click).

More specific:

[code]Mouse 1 T A Window-Raise-RaiseMove

DestroyFunc Window-Raise-RaiseMove
AddToFunc Window-Raise-RaiseMove

  • C Raise
  • M Raise
  • M Move
  • I State 11 False
  • C Window-Opacize
  • M Window-Opacize
  • I Window-DeOpacize

DestroyFunc Window-DeOpacize
AddToFunc Window-DeOpacize

  • I Current (!State 11) Exec exec transset-df --id “$[w.id]” --dec 0.5
  • I State 11 True

DestroyFunc Window-Opacize
AddToFunc Window-Opacize

  • I Current (State 11) Exec exec transset-df --id “$[w.id]” --inc 0.5
  • I State 11 True[/code]

What I want:

  • If i just click the window is Raised (OK) but is not faded (NOTOK) (actually fade and return normal but it’s annoying; this is what i want to avoid)
  • If i move, windows is moved (OK) and is faded (OK); on button release return normal (OK)
  • If i hold mouse button the window fade (OK); on button release return normal (OK)
  • The release after an hold is considered a click (OK)

What I tried:

  • “+ I Schedule 500 Window-DeOpacize” but the schedule is executed after the button’s release
  • “+ I PipeRead 'sleep 0.5 && echo Window-DeOpacize” but PipeRead is synchronous so an eventual Click is executed after Window-DeOpacize
  • “+ H Window-DeOpacize” but the button release is not considered a click and i can’t Opacize again nor Raise

Do you have any suggestion? Or this can’t be done? I’m out of clues …

Thanks in advance :slight_smile:

Hmm, tricky – the pointer is grabbed throughout the lifetime of the function.

You have to do it post button release. PipeRead is your best bet here.

– Thomas Adam

[code]DestroyFunc Window-Raise-RaiseMove
AddToFunc Window-Raise-RaiseMove

  • C Raise
  • M PipeRead ‘transset-df --id ‘$[w.id]’ --dec 0.5 && echo Move’
  • M Schedule 100 Exec exec transset-df --id “$[w.id]” --inc 0.5
  • M Raise
  • H Exec exec transset-df --id “$[w.id]” --dec 0.5
  • H Move
  • H Schedule 100 Exec exec transset-df --id “$[w.id]” --inc 0.5
  • H Raise[/code]

I solved with this ^^
Actually the delay is ClickTime and for me it’s enought. If someone need more can either increment ClickTime or change

+ H Exec exec transset-df --id "$[w.id]" --dec 0.5

with

+ H PipeRead 'sleep 1 && transset-df --id '$[w.id]'--dec 0.5 && echo Nop'

for [1s + ClickTime] delay.

The little trick is that Scheduled commands are executed after the function’s end, independently from their delay. I set it at 100 because 2 transset-df calls (Increase on Hold and Scheduled Decrease) on the same windows short-after give me troubles :S

Thanks for the fast reply :slight_smile: