~azzar1/unity/fix-1028810

« back to all changes in this revision

Viewing changes to launcher/Launcher.cpp

  • Committer: Andrea Azzarone
  • Date: 2012-08-22 13:14:18 UTC
  • mfrom: (2516.1.92 unity)
  • Revision ID: azzaronea@gmail.com-20120822131418-mrfwx82k39xnvl9e
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
198
198
 
199
199
  ubus_.RegisterInterest(UBUS_OVERLAY_SHOWN, sigc::mem_fun(this, &Launcher::OnOverlayShown));
200
200
  ubus_.RegisterInterest(UBUS_OVERLAY_HIDDEN, sigc::mem_fun(this, &Launcher::OnOverlayHidden));
201
 
  ubus_.RegisterInterest(UBUS_LAUNCHER_ACTION_DONE, sigc::mem_fun(this, &Launcher::OnActionDone));
202
201
  ubus_.RegisterInterest(UBUS_BACKGROUND_COLOR_CHANGED, sigc::mem_fun(this, &Launcher::OnBGColorChanged));
203
202
  ubus_.RegisterInterest(UBUS_LAUNCHER_LOCK_HIDE, sigc::mem_fun(this, &Launcher::OnLockHideChanged));
204
203
 
373
372
 
374
373
bool Launcher::IconNeedsAnimation(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const
375
374
{
376
 
  struct timespec time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_VISIBLE);
377
 
  if (unity::TimeUtil::TimeDelta(&current, &time) < ANIM_DURATION_SHORT)
378
 
    return true;
379
 
 
380
 
  time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_RUNNING);
381
 
  if (unity::TimeUtil::TimeDelta(&current, &time) < ANIM_DURATION_SHORT)
382
 
    return true;
383
 
 
384
 
  time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_STARTING);
 
375
  struct timespec time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::VISIBLE);
 
376
  if (unity::TimeUtil::TimeDelta(&current, &time) < ANIM_DURATION_SHORT)
 
377
    return true;
 
378
 
 
379
  time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::RUNNING);
 
380
  if (unity::TimeUtil::TimeDelta(&current, &time) < ANIM_DURATION_SHORT)
 
381
    return true;
 
382
 
 
383
  time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::STARTING);
385
384
  if (unity::TimeUtil::TimeDelta(&current, &time) < (ANIM_DURATION_LONG * MAX_STARTING_BLINKS * STARTING_BLINK_LAMBDA * 2))
386
385
    return true;
387
386
 
388
 
  time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_URGENT);
 
387
  time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::URGENT);
389
388
  if (unity::TimeUtil::TimeDelta(&current, &time) < (ANIM_DURATION_LONG * URGENT_BLINKS * 2))
390
389
    return true;
391
390
 
392
 
  time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_PULSE_ONCE);
 
391
  time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::PULSE_ONCE);
393
392
  if (unity::TimeUtil::TimeDelta(&current, &time) < (ANIM_DURATION_LONG * PULSE_BLINK_LAMBDA * 2))
394
393
    return true;
395
394
 
396
 
  time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_PRESENTED);
 
395
  time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::PRESENTED);
397
396
  if (unity::TimeUtil::TimeDelta(&current, &time) < ANIM_DURATION)
398
397
    return true;
399
398
 
400
 
  time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_SHIMMER);
 
399
  time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::SHIMMER);
401
400
  if (unity::TimeUtil::TimeDelta(&current, &time) < ANIM_DURATION_LONG)
402
401
    return true;
403
402
 
404
 
  time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_CENTER_SAVED);
405
 
  if (unity::TimeUtil::TimeDelta(&current, &time) < ANIM_DURATION)
406
 
    return true;
407
 
 
408
 
  time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_PROGRESS);
409
 
  if (unity::TimeUtil::TimeDelta(&current, &time) < ANIM_DURATION)
410
 
    return true;
411
 
 
412
 
  time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_DROP_DIM);
413
 
  if (unity::TimeUtil::TimeDelta(&current, &time) < ANIM_DURATION)
414
 
    return true;
415
 
 
416
 
  time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_DESAT);
 
403
  time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::CENTER_SAVED);
 
404
  if (unity::TimeUtil::TimeDelta(&current, &time) < ANIM_DURATION)
 
405
    return true;
 
406
 
 
407
  time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::PROGRESS);
 
408
  if (unity::TimeUtil::TimeDelta(&current, &time) < ANIM_DURATION)
 
409
    return true;
 
410
 
 
411
  time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::DROP_DIM);
 
412
  if (unity::TimeUtil::TimeDelta(&current, &time) < ANIM_DURATION)
 
413
    return true;
 
414
 
 
415
  time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::DESAT);
417
416
  if (unity::TimeUtil::TimeDelta(&current, &time) < ANIM_DURATION_SHORT_SHORT)
418
417
    return true;
419
418
 
420
 
  time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_DROP_PRELIGHT);
 
419
  time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::DROP_PRELIGHT);
421
420
  if (unity::TimeUtil::TimeDelta(&current, &time) < ANIM_DURATION)
422
421
    return true;
423
422
 
496
495
  if (!icon->IsVisibleOnMonitor(monitor))
497
496
    return 0.0f;
498
497
 
499
 
  if (icon->GetIconType() == AbstractLauncherIcon::TYPE_HUD)
 
498
  if (icon->GetIconType() == AbstractLauncherIcon::IconType::HUD)
500
499
  {
501
 
    return (icon->GetQuirk(AbstractLauncherIcon::QUIRK_VISIBLE)) ? 1.0f : 0.0f;
 
500
    return (icon->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE)) ? 1.0f : 0.0f;
502
501
  }
503
502
 
504
 
  if (icon->GetQuirk(AbstractLauncherIcon::QUIRK_VISIBLE))
 
503
  if (icon->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE))
505
504
  {
506
 
    struct timespec icon_visible_time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_VISIBLE);
 
505
    struct timespec icon_visible_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::VISIBLE);
507
506
    int enter_ms = unity::TimeUtil::TimeDelta(&current, &icon_visible_time);
508
507
    return CLAMP((float) enter_ms / (float) ANIM_DURATION_SHORT, 0.0f, 1.0f);
509
508
  }
510
509
  else
511
510
  {
512
 
    struct timespec icon_hide_time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_VISIBLE);
 
511
    struct timespec icon_hide_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::VISIBLE);
513
512
    int hide_ms = unity::TimeUtil::TimeDelta(&current, &icon_hide_time);
514
513
    return 1.0f - CLAMP((float) hide_ms / (float) ANIM_DURATION_SHORT, 0.0f, 1.0f);
515
514
  }
542
541
 
543
542
float Launcher::IconPresentProgress(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const
544
543
{
545
 
  struct timespec icon_present_time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_PRESENTED);
 
544
  struct timespec icon_present_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::PRESENTED);
546
545
  int ms = unity::TimeUtil::TimeDelta(&current, &icon_present_time);
547
546
  float result = CLAMP((float) ms / (float) ANIM_DURATION, 0.0f, 1.0f);
548
547
 
549
 
  if (icon->GetQuirk(AbstractLauncherIcon::QUIRK_PRESENTED))
 
548
  if (icon->GetQuirk(AbstractLauncherIcon::Quirk::PRESENTED))
550
549
    return result;
551
550
  else
552
551
    return 1.0f - result;
554
553
 
555
554
float Launcher::IconUrgentProgress(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const
556
555
{
557
 
  struct timespec urgent_time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_URGENT);
 
556
  struct timespec urgent_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::URGENT);
558
557
  int urgent_ms = unity::TimeUtil::TimeDelta(&current, &urgent_time);
559
558
  float result;
560
559
 
563
562
  else
564
563
    result = CLAMP((float) urgent_ms / (float)(ANIM_DURATION_LONG * URGENT_BLINKS * 2), 0.0f, 1.0f);
565
564
 
566
 
  if (icon->GetQuirk(AbstractLauncherIcon::QUIRK_URGENT))
 
565
  if (icon->GetQuirk(AbstractLauncherIcon::Quirk::URGENT))
567
566
    return result;
568
567
  else
569
568
    return 1.0f - result;
571
570
 
572
571
float Launcher::IconDropDimValue(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const
573
572
{
574
 
  struct timespec dim_time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_DROP_DIM);
 
573
  struct timespec dim_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::DROP_DIM);
575
574
  int dim_ms = unity::TimeUtil::TimeDelta(&current, &dim_time);
576
575
  float result = CLAMP((float) dim_ms / (float) ANIM_DURATION, 0.0f, 1.0f);
577
576
 
578
 
  if (icon->GetQuirk(AbstractLauncherIcon::QUIRK_DROP_DIM))
 
577
  if (icon->GetQuirk(AbstractLauncherIcon::Quirk::DROP_DIM))
579
578
    return 1.0f - result;
580
579
  else
581
580
    return result;
583
582
 
584
583
float Launcher::IconDesatValue(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const
585
584
{
586
 
  struct timespec dim_time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_DESAT);
 
585
  struct timespec dim_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::DESAT);
587
586
  int ms = unity::TimeUtil::TimeDelta(&current, &dim_time);
588
587
  float result = CLAMP((float) ms / (float) ANIM_DURATION_SHORT_SHORT, 0.0f, 1.0f);
589
588
 
590
 
  if (icon->GetQuirk(AbstractLauncherIcon::QUIRK_DESAT))
 
589
  if (icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT))
591
590
    return 1.0f - result;
592
591
  else
593
592
    return result;
595
594
 
596
595
float Launcher::IconShimmerProgress(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const
597
596
{
598
 
  struct timespec shimmer_time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_SHIMMER);
 
597
  struct timespec shimmer_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::SHIMMER);
599
598
  int shimmer_ms = unity::TimeUtil::TimeDelta(&current, &shimmer_time);
600
599
  return CLAMP((float) shimmer_ms / (float) ANIM_DURATION_LONG, 0.0f, 1.0f);
601
600
}
602
601
 
603
602
float Launcher::IconCenterTransitionProgress(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const
604
603
{
605
 
  struct timespec save_time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_CENTER_SAVED);
 
604
  struct timespec save_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::CENTER_SAVED);
606
605
  int save_ms = unity::TimeUtil::TimeDelta(&current, &save_time);
607
606
  return CLAMP((float) save_ms / (float) ANIM_DURATION, 0.0f, 1.0f);
608
607
}
609
608
 
610
609
float Launcher::IconUrgentPulseValue(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const
611
610
{
612
 
  if (!icon->GetQuirk(AbstractLauncherIcon::QUIRK_URGENT))
 
611
  if (!icon->GetQuirk(AbstractLauncherIcon::Quirk::URGENT))
613
612
    return 1.0f; // we are full on in a normal condition
614
613
 
615
614
  double urgent_progress = (double) IconUrgentProgress(icon, current);
618
617
 
619
618
float Launcher::IconPulseOnceValue(AbstractLauncherIcon::Ptr icon, struct timespec const &current) const
620
619
{
621
 
  struct timespec pulse_time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_PULSE_ONCE);
 
620
  struct timespec pulse_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::PULSE_ONCE);
622
621
  int pulse_ms = unity::TimeUtil::TimeDelta(&current, &pulse_time);
623
622
  double pulse_progress = (double) CLAMP((float) pulse_ms / (ANIM_DURATION_LONG * PULSE_BLINK_LAMBDA * 2), 0.0f, 1.0f);
624
623
 
625
624
  if (pulse_progress == 1.0f)
626
 
    icon->SetQuirk(AbstractLauncherIcon::QUIRK_PULSE_ONCE, false);
 
625
    icon->SetQuirk(AbstractLauncherIcon::Quirk::PULSE_ONCE, false);
627
626
 
628
627
  return 0.5f + (float) (std::cos(M_PI * 2.0 * pulse_progress)) * 0.5f;
629
628
}
630
629
 
631
630
float Launcher::IconUrgentWiggleValue(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const
632
631
{
633
 
  if (!icon->GetQuirk(AbstractLauncherIcon::QUIRK_URGENT))
 
632
  if (!icon->GetQuirk(AbstractLauncherIcon::Quirk::URGENT))
634
633
    return 0.0f; // we are full on in a normal condition
635
634
 
636
635
  double urgent_progress = (double) IconUrgentProgress(icon, current);
639
638
 
640
639
float Launcher::IconStartingBlinkValue(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const
641
640
{
642
 
  struct timespec starting_time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_STARTING);
 
641
  struct timespec starting_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::STARTING);
643
642
  int starting_ms = unity::TimeUtil::TimeDelta(&current, &starting_time);
644
643
  double starting_progress = (double) CLAMP((float) starting_ms / (float)(ANIM_DURATION_LONG * STARTING_BLINK_LAMBDA), 0.0f, 1.0f);
645
644
  double val = IsBackLightModeToggles() ? 3.0f : 4.0f;
648
647
 
649
648
float Launcher::IconStartingPulseValue(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const
650
649
{
651
 
  struct timespec starting_time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_STARTING);
 
650
  struct timespec starting_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::STARTING);
652
651
  int starting_ms = unity::TimeUtil::TimeDelta(&current, &starting_time);
653
652
  double starting_progress = (double) CLAMP((float) starting_ms / (float)(ANIM_DURATION_LONG * MAX_STARTING_BLINKS * STARTING_BLINK_LAMBDA * 2), 0.0f, 1.0f);
654
653
 
655
 
  if (starting_progress == 1.0f && !icon->GetQuirk(AbstractLauncherIcon::QUIRK_RUNNING))
 
654
  if (starting_progress == 1.0f && !icon->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING))
656
655
  {
657
 
    icon->SetQuirk(AbstractLauncherIcon::QUIRK_STARTING, false);
658
 
    icon->ResetQuirkTime(AbstractLauncherIcon::QUIRK_STARTING);
 
656
    icon->SetQuirk(AbstractLauncherIcon::Quirk::STARTING, false);
 
657
    icon->ResetQuirkTime(AbstractLauncherIcon::Quirk::STARTING);
659
658
  }
660
659
 
661
660
  return 0.5f + (float)(std::cos(M_PI * (float)(MAX_STARTING_BLINKS * 2) * starting_progress)) * 0.5f;
665
664
{
666
665
  float result = 0.0f;
667
666
 
668
 
  struct timespec running_time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_RUNNING);
 
667
  struct timespec running_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::RUNNING);
669
668
  int running_ms = unity::TimeUtil::TimeDelta(&current, &running_time);
670
669
  float running_progress = CLAMP((float) running_ms / (float) ANIM_DURATION_SHORT, 0.0f, 1.0f);
671
670
 
672
 
  if (!icon->GetQuirk(AbstractLauncherIcon::QUIRK_RUNNING))
 
671
  if (!icon->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING))
673
672
    running_progress = 1.0f - running_progress;
674
673
 
675
674
  // After we finish a fade in from running, we can reset the quirk
676
 
  if (running_progress == 1.0f && icon->GetQuirk(AbstractLauncherIcon::QUIRK_RUNNING))
677
 
    icon->SetQuirk(AbstractLauncherIcon::QUIRK_STARTING, false);
 
675
  if (running_progress == 1.0f && icon->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING))
 
676
    icon->SetQuirk(AbstractLauncherIcon::Quirk::STARTING, false);
678
677
 
679
678
  float backlight_strength;
680
679
  if (options()->backlight_mode() == BACKLIGHT_ALWAYS_ON)
698
697
        result = backlight_strength; // The blink concept is a failure in this case (it just doesn't work right)
699
698
      break;
700
699
    case LAUNCH_ANIMATION_PULSE:
701
 
      if (running_progress == 1.0f && icon->GetQuirk(AbstractLauncherIcon::QUIRK_RUNNING))
702
 
        icon->ResetQuirkTime(AbstractLauncherIcon::QUIRK_STARTING);
 
700
      if (running_progress == 1.0f && icon->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING))
 
701
        icon->ResetQuirkTime(AbstractLauncherIcon::Quirk::STARTING);
703
702
 
704
703
      result = backlight_strength;
705
704
      if (options()->backlight_mode() == BACKLIGHT_ALWAYS_ON)
711
710
      break;
712
711
  }
713
712
 
714
 
  if (icon->GetQuirk(AbstractLauncherIcon::QUIRK_PULSE_ONCE))
 
713
  if (icon->GetQuirk(AbstractLauncherIcon::Quirk::PULSE_ONCE))
715
714
  {
716
715
    if (options()->backlight_mode() == BACKLIGHT_ALWAYS_ON)
717
716
      result *= CLAMP(running_progress + IconPulseOnceValue(icon, current), 0.0f, 1.0f);
722
721
  }
723
722
 
724
723
  // urgent serves to bring the total down only
725
 
  if (icon->GetQuirk(AbstractLauncherIcon::QUIRK_URGENT) && options()->urgent_animation() == URGENT_ANIMATION_PULSE)
 
724
  if (icon->GetQuirk(AbstractLauncherIcon::Quirk::URGENT) && options()->urgent_animation() == URGENT_ANIMATION_PULSE)
726
725
    result *= 0.2f + 0.8f * IconUrgentPulseValue(icon, current);
727
726
 
728
727
  return result;
730
729
 
731
730
float Launcher::IconProgressBias(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const
732
731
{
733
 
  struct timespec icon_progress_time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_PROGRESS);
 
732
  struct timespec icon_progress_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::PROGRESS);
734
733
  int ms = unity::TimeUtil::TimeDelta(&current, &icon_progress_time);
735
734
  float result = CLAMP((float) ms / (float) ANIM_DURATION, 0.0f, 1.0f);
736
735
 
737
 
  if (icon->GetQuirk(AbstractLauncherIcon::QUIRK_PROGRESS))
 
736
  if (icon->GetQuirk(AbstractLauncherIcon::Quirk::PROGRESS))
738
737
    return -1.0f + result;
739
738
  else
740
739
    return result;
758
757
  arg.alpha               = 0.2f + 0.8f * desat_value;
759
758
  arg.saturation          = desat_value;
760
759
  arg.colorify            = nux::color::White;
761
 
  arg.running_arrow       = icon->GetQuirk(AbstractLauncherIcon::QUIRK_RUNNING);
762
 
  arg.running_colored     = icon->GetQuirk(AbstractLauncherIcon::QUIRK_URGENT);
 
760
  arg.running_arrow       = icon->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING);
 
761
  arg.running_colored     = icon->GetQuirk(AbstractLauncherIcon::Quirk::URGENT);
763
762
  arg.draw_edge_only      = IconDrawEdgeOnly(icon);
764
763
  arg.active_colored      = false;
765
764
  arg.x_rotation          = 0.0f;
771
770
  arg.progress_bias       = IconProgressBias(icon, current);
772
771
  arg.progress            = CLAMP(icon->GetProgress(), 0.0f, 1.0f);
773
772
  arg.draw_shortcut       = _shortcuts_shown && !_hide_machine.GetQuirk(LauncherHideMachine::PLACES_VISIBLE);
774
 
  arg.system_item         = icon->GetIconType() == AbstractLauncherIcon::TYPE_HOME    ||
775
 
                            icon->GetIconType() == AbstractLauncherIcon::TYPE_HUD;
776
 
  arg.colorify_background = icon->GetIconType() == AbstractLauncherIcon::TYPE_HOME    ||
777
 
                            icon->GetIconType() == AbstractLauncherIcon::TYPE_HUD     ||
778
 
                            icon->GetIconType() == AbstractLauncherIcon::TYPE_TRASH   ||
779
 
                            icon->GetIconType() == AbstractLauncherIcon::TYPE_DESKTOP ||
780
 
                            icon->GetIconType() == AbstractLauncherIcon::TYPE_DEVICE  ||
781
 
                            icon->GetIconType() == AbstractLauncherIcon::TYPE_EXPO;
 
773
  arg.system_item         = icon->GetIconType() == AbstractLauncherIcon::IconType::HOME    ||
 
774
                            icon->GetIconType() == AbstractLauncherIcon::IconType::HUD;
 
775
  arg.colorify_background = icon->GetIconType() == AbstractLauncherIcon::IconType::HOME    ||
 
776
                            icon->GetIconType() == AbstractLauncherIcon::IconType::HUD     ||
 
777
                            icon->GetIconType() == AbstractLauncherIcon::IconType::TRASH   ||
 
778
                            icon->GetIconType() == AbstractLauncherIcon::IconType::DESKTOP ||
 
779
                            icon->GetIconType() == AbstractLauncherIcon::IconType::DEVICE  ||
 
780
                            icon->GetIconType() == AbstractLauncherIcon::IconType::EXPO;
782
781
 
783
782
  // trying to protect against flickering when icon is dragged from dash LP: #863230
784
783
  if (arg.alpha < 0.2)
787
786
    arg.saturation = 0.0;
788
787
  }
789
788
 
790
 
  arg.active_arrow = icon->GetQuirk(AbstractLauncherIcon::QUIRK_ACTIVE);
 
789
  arg.active_arrow = icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE);
791
790
 
792
791
  /* BFB or HUD icons don't need the active arrow if the overaly is opened
793
792
   * in another monitor */
794
793
  if (arg.active_arrow && !IsOverlayOpen() &&
795
 
      (icon->GetIconType() == AbstractLauncherIcon::TYPE_HOME ||
796
 
       icon->GetIconType() == AbstractLauncherIcon::TYPE_HUD))
 
794
      (icon->GetIconType() == AbstractLauncherIcon::IconType::HOME ||
 
795
       icon->GetIconType() == AbstractLauncherIcon::IconType::HUD))
797
796
  {
798
797
    arg.active_arrow = false;
799
798
  }
810
809
    arg.shortcut_label = 0;
811
810
 
812
811
  // we dont need to show strays
813
 
  if (!icon->GetQuirk(AbstractLauncherIcon::QUIRK_RUNNING))
 
812
  if (!icon->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING))
814
813
  {
815
 
    if (icon->GetQuirk(AbstractLauncherIcon::QUIRK_URGENT))
 
814
    if (icon->GetQuirk(AbstractLauncherIcon::Quirk::URGENT))
816
815
    {
817
816
      arg.running_arrow = true;
818
817
      arg.window_indicators = 1;
833
832
 
834
833
  float urgent_progress = IconUrgentProgress(icon, current);
835
834
 
836
 
  if (icon->GetQuirk(AbstractLauncherIcon::QUIRK_URGENT))
 
835
  if (icon->GetQuirk(AbstractLauncherIcon::Quirk::URGENT))
837
836
    urgent_progress = CLAMP(urgent_progress * 3.0f, 0.0f, 1.0f);  // we want to go 3x faster than the urgent normal cycle
838
837
  else
839
838
    urgent_progress = CLAMP(urgent_progress * 3.0f - 2.0f, 0.0f, 1.0f);  // we want to go 3x faster than the urgent normal cycle
840
839
  arg.glow_intensity = urgent_progress;
841
840
 
842
 
  if (icon->GetQuirk(AbstractLauncherIcon::QUIRK_URGENT) && options()->urgent_animation() == URGENT_ANIMATION_WIGGLE)
 
841
  if (icon->GetQuirk(AbstractLauncherIcon::Quirk::URGENT) && options()->urgent_animation() == URGENT_ANIMATION_WIGGLE)
843
842
  {
844
843
    arg.z_rotation = IconUrgentWiggleValue(icon, current);
845
844
  }
1057
1056
  last_geo = box_geo;
1058
1057
  _enter_y = 0;
1059
1058
 
 
1059
  
 
1060
  // logically dnd exit only restores to the clamped ranges
 
1061
  // hover_progress restores to 0
 
1062
  _launcher_drag_delta_max = 0.0f;
 
1063
  _launcher_drag_delta_min = MIN(0.0f, launcher_height - sum);
 
1064
 
1060
1065
  if (hover_progress > 0.0f && _launcher_drag_delta != 0)
1061
1066
  {
1062
1067
    float delta_y = _launcher_drag_delta;
1063
1068
 
1064
 
    // logically dnd exit only restores to the clamped ranges
1065
 
    // hover_progress restores to 0
1066
 
    _launcher_drag_delta_max = 0.0f;
1067
 
    _launcher_drag_delta_min = MIN(0.0f, launcher_height - sum);
1068
 
 
1069
1069
    if (_launcher_drag_delta > _launcher_drag_delta_max)
1070
1070
      delta_y = _launcher_drag_delta_max + DragLimiter(delta_y - _launcher_drag_delta_max);
1071
1071
    else if (_launcher_drag_delta < _launcher_drag_delta_min)
1181
1181
{
1182
1182
  for (auto icon : *_model)
1183
1183
  {
1184
 
    if (icon->GetIconType () != AbstractLauncherIcon::TYPE_HOME &&
1185
 
        icon->GetIconType () != AbstractLauncherIcon::TYPE_HUD)
 
1184
    if (icon->GetIconType () != AbstractLauncherIcon::IconType::HOME &&
 
1185
        icon->GetIconType () != AbstractLauncherIcon::IconType::HUD)
1186
1186
    {
1187
 
      icon->SetQuirk(AbstractLauncherIcon::QUIRK_DESAT, true);
 
1187
      icon->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, true);
1188
1188
    }
1189
1189
 
1190
1190
    icon->HideTooltip();
1195
1195
{
1196
1196
  for (auto icon : *_model)
1197
1197
  {
1198
 
    icon->SetQuirk(AbstractLauncherIcon::QUIRK_DESAT, false);
 
1198
    icon->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, false);
1199
1199
  }
1200
1200
}
1201
1201
 
1290
1290
  return _dash_is_open || _hud_is_open;
1291
1291
}
1292
1292
 
1293
 
void Launcher::OnActionDone(GVariant* data)
1294
 
{
1295
 
  _hide_machine.SetQuirk(LauncherHideMachine::LAST_ACTION_ACTIVATE, true);
1296
 
}
1297
 
 
1298
 
void Launcher::SetHidden(bool hidden)
1299
 
{
1300
 
  if (hidden == _hidden)
 
1293
void Launcher::SetHidden(bool hide_launcher)
 
1294
{
 
1295
  if (hide_launcher == _hidden)
1301
1296
    return;
1302
1297
 
1303
 
  _hidden = hidden;
1304
 
  _hide_machine.SetQuirk(LauncherHideMachine::LAUNCHER_HIDDEN, hidden);
1305
 
  _hover_machine.SetQuirk(LauncherHoverMachine::LAUNCHER_HIDDEN, hidden);
1306
 
 
1307
 
  _hide_machine.SetQuirk(LauncherHideMachine::LAST_ACTION_ACTIVATE, false);
1308
 
 
1309
 
  if (hidden)
 
1298
  _hidden = hide_launcher;
 
1299
  _hide_machine.SetQuirk(LauncherHideMachine::LAUNCHER_HIDDEN, hide_launcher);
 
1300
  _hover_machine.SetQuirk(LauncherHoverMachine::LAUNCHER_HIDDEN, hide_launcher);
 
1301
 
 
1302
  if (hide_launcher)
1310
1303
  {
1311
1304
    _hide_machine.SetQuirk(LauncherHideMachine::MOUSE_MOVE_POST_REVEAL, false);
1312
1305
    _hide_machine.SetQuirk(LauncherHideMachine::MT_DRAG_OUT, false);
1318
1311
 
1319
1312
  TimeUtil::SetTimeStruct(&_times[TIME_AUTOHIDE], &_times[TIME_AUTOHIDE], ANIM_DURATION_SHORT);
1320
1313
 
1321
 
  _parent->EnableInputWindow(!hidden, launcher::window_title, false, false);
 
1314
  _parent->EnableInputWindow(!hide_launcher, launcher::window_title, false, false);
1322
1315
 
1323
 
  if (!hidden && GetActionState() == ACTION_DRAG_EXTERNAL)
 
1316
  if (!hide_launcher && GetActionState() == ACTION_DRAG_EXTERNAL)
1324
1317
    DndReset();
1325
1318
 
1326
1319
  EnsureAnimation();
1328
1321
  hidden_changed.emit();
1329
1322
}
1330
1323
 
 
1324
void Launcher::UpdateChangeInMousePosition(int delta_x, int delta_y)
 
1325
{
 
1326
  _postreveal_mousemove_delta_x += delta_x;
 
1327
  _postreveal_mousemove_delta_y += delta_y;
 
1328
 
 
1329
  // check the state before changing it to avoid uneeded hide calls
 
1330
  if (!_hide_machine.GetQuirk(LauncherHideMachine::MOUSE_MOVE_POST_REVEAL) &&
 
1331
     (nux::Abs(_postreveal_mousemove_delta_x) > MOUSE_DEADZONE ||
 
1332
     nux::Abs(_postreveal_mousemove_delta_y) > MOUSE_DEADZONE))
 
1333
       _hide_machine.SetQuirk(LauncherHideMachine::MOUSE_MOVE_POST_REVEAL, true);
 
1334
}
 
1335
 
 
1336
 
1331
1337
int Launcher::GetMouseX() const
1332
1338
{
1333
1339
  return _mouse_position.x;
1447
1453
 
1448
1454
void Launcher::UpdateOptions(Options::Ptr options)
1449
1455
{
 
1456
  SetIconSize(options->tile_size, options->icon_size);
1450
1457
  SetHideMode(options->hide_mode);
1451
 
  SetIconSize(options->tile_size, options->icon_size);
1452
1458
 
1453
1459
  ConfigureBarrier();
1454
1460
  EnsureAnimation();
1473
1479
  }
1474
1480
  else
1475
1481
  {
 
1482
    static bool first_time = true;
 
1483
 
1476
1484
    _parent->EnableInputWindow(true, launcher::window_title, false, false);
1477
1485
 
1478
 
    if (!sources_.GetSource(STRUT_HACK_TIMEOUT))
 
1486
    if (first_time && !sources_.GetSource(STRUT_HACK_TIMEOUT))
1479
1487
    {
1480
1488
      sources_.AddTimeout(1000, sigc::mem_fun(this, &Launcher::StrutHack), STRUT_HACK_TIMEOUT);
 
1489
      first_time = false;
1481
1490
    }
1482
1491
 
1483
1492
    _parent->InputWindowEnableStruts(true);
1504
1513
  }
1505
1514
}
1506
1515
 
1507
 
nux::ObjectPtr<nux::View> Launcher::GetActiveTooltip() const
 
1516
nux::ObjectPtr<nux::View> const& Launcher::GetActiveTooltip() const
1508
1517
{
1509
1518
  return _active_tooltip;
1510
1519
}
1511
1520
 
 
1521
nux::ObjectPtr<LauncherDragWindow> const& Launcher::GetDraggedIcon() const
 
1522
{
 
1523
  return _drag_window;
 
1524
}
 
1525
 
1512
1526
void Launcher::SetActionState(LauncherActionState actionstate)
1513
1527
{
1514
1528
  if (_launcher_action_state == actionstate)
1712
1726
  int natural_y = 0;
1713
1727
  for (auto icon : *_model)
1714
1728
  {
1715
 
    if (!icon->GetQuirk(AbstractLauncherIcon::QUIRK_VISIBLE) || !icon->IsVisibleOnMonitor(monitor))
 
1729
    if (!icon->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE) || !icon->IsVisibleOnMonitor(monitor))
1716
1730
      continue;
1717
1731
 
1718
1732
    if (icon == selection)
2015
2029
 
2016
2030
  // FIXME: nux doesn't give nux::GetEventButton (button_flags) there, relying
2017
2031
  // on an internal Launcher property then
2018
 
  if (drag_icon && (_last_button_press == 1) && _model->IconHasSister(drag_icon))
 
2032
  if (drag_icon && _last_button_press == 1 && _model->IconHasSister(drag_icon))
2019
2033
  {
2020
2034
    SetActionState(ACTION_DRAG_ICON);
2021
2035
    StartIconDrag(drag_icon);
2065
2079
  {
2066
2080
    AbstractLauncherIcon::Ptr hovered_icon = MouseIconIntersection(_mouse_position.x, _mouse_position.y);
2067
2081
 
2068
 
    if (hovered_icon && hovered_icon->GetIconType() == AbstractLauncherIcon::TYPE_TRASH)
 
2082
    if (hovered_icon && hovered_icon->GetIconType() == AbstractLauncherIcon::IconType::TRASH)
2069
2083
    {
2070
 
      hovered_icon->SetQuirk(AbstractLauncherIcon::QUIRK_PULSE_ONCE, true);
 
2084
      hovered_icon->SetQuirk(AbstractLauncherIcon::Quirk::PULSE_ONCE, true);
2071
2085
 
2072
2086
      launcher_removerequest.emit(_drag_icon);
2073
2087
 
2126
2140
          LauncherModel::iterator prevIt = _model->end();
2127
2141
          for (it = _model->begin(); it != _model->end(); ++it)
2128
2142
          {
2129
 
            if (!(*it)->GetQuirk(AbstractLauncherIcon::QUIRK_VISIBLE) || !(*it)->IsVisibleOnMonitor(monitor))
 
2143
            if (!(*it)->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE) || !(*it)->IsVisibleOnMonitor(monitor))
2130
2144
              continue;
2131
2145
 
2132
2146
            if ((*it) == hovered_icon) {
2144
2158
          }
2145
2159
        }
2146
2160
      }
 
2161
 
 
2162
      if (progress >= 1.0f)
 
2163
      {
 
2164
        _model->ReorderSmart(_drag_icon, hovered_icon, true);
 
2165
      }
 
2166
      else if (progress == 0.0f)
 
2167
      {
 
2168
        _model->ReorderBefore(_drag_icon, hovered_icon, false);
 
2169
      }
2147
2170
    }
2148
2171
  }
2149
2172
}
2247
2270
void Launcher::RecvMouseLeave(int x, int y, unsigned long button_flags, unsigned long key_flags)
2248
2271
{
2249
2272
  SetStateMouseOverLauncher(false);
2250
 
 
2251
2273
  EventLogic();
2252
2274
  EnsureAnimation();
2253
2275
}
2257
2279
  SetMousePosition(x, y);
2258
2280
 
2259
2281
  if (!_hidden)
2260
 
  {
2261
 
    _postreveal_mousemove_delta_x += dx;
2262
 
    _postreveal_mousemove_delta_y += dy;
2263
 
 
2264
 
    // check the state before changing it to avoid uneeded hide calls
2265
 
    if (!_hide_machine.GetQuirk(LauncherHideMachine::MOUSE_MOVE_POST_REVEAL) &&
2266
 
        (nux::Abs(_postreveal_mousemove_delta_x) > MOUSE_DEADZONE ||
2267
 
         nux::Abs(_postreveal_mousemove_delta_y) > MOUSE_DEADZONE))
2268
 
      _hide_machine.SetQuirk(LauncherHideMachine::MOUSE_MOVE_POST_REVEAL, true);
2269
 
  }
2270
 
 
2271
 
 
 
2282
    UpdateChangeInMousePosition(dx, dy);
2272
2283
 
2273
2284
  // Every time the mouse moves, we check if it is inside an icon...
2274
2285
  EventLogic();
2407
2418
  {
2408
2419
    launcher_icon->mouse_enter.emit(monitor);
2409
2420
    _icon_under_mouse = launcher_icon;
2410
 
 
2411
 
    _hide_machine.SetQuirk(LauncherHideMachine::LAST_ACTION_ACTIVATE, false);
2412
2421
  }
2413
2422
}
2414
2423
 
2417
2426
  AbstractLauncherIcon::Ptr launcher_icon;
2418
2427
  launcher_icon = MouseIconIntersection(_mouse_position.x, _mouse_position.y);
2419
2428
 
2420
 
  _hide_machine.SetQuirk(LauncherHideMachine::LAST_ACTION_ACTIVATE, false);
2421
 
 
2422
2429
  if (launcher_icon)
2423
2430
  {
2424
2431
    _icon_mouse_down = launcher_icon;
2470
2477
 
2471
2478
  for (it = _model->begin(); it != _model->end(); ++it)
2472
2479
  {
2473
 
    if (!(*it)->GetQuirk(AbstractLauncherIcon::QUIRK_VISIBLE) || !(*it)->IsVisibleOnMonitor(monitor))
 
2480
    if (!(*it)->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE) || !(*it)->IsVisibleOnMonitor(monitor))
2474
2481
      continue;
2475
2482
 
2476
2483
    nux::Point2 screen_coord [4];
2587
2594
    {
2588
2595
      if (it->ShouldHighlightOnDrag(_dnd_data))
2589
2596
      {
2590
 
        it->SetQuirk(AbstractLauncherIcon::QUIRK_DESAT, false);
2591
 
        it->SetQuirk(AbstractLauncherIcon::QUIRK_PRESENTED, true);
 
2597
        it->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, false);
 
2598
        it->SetQuirk(AbstractLauncherIcon::Quirk::PRESENTED, true);
2592
2599
      }
2593
2600
      else
2594
2601
      {
2595
 
        it->SetQuirk(AbstractLauncherIcon::QUIRK_DESAT, true);
2596
 
        it->SetQuirk(AbstractLauncherIcon::QUIRK_PRESENTED, false);
 
2602
        it->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, true);
 
2603
        it->SetQuirk(AbstractLauncherIcon::Quirk::PRESENTED, false);
2597
2604
      }
2598
2605
    }
2599
2606
  }
2624
2631
 
2625
2632
  for (auto it : *_model)
2626
2633
  {
2627
 
    it->SetQuirk(AbstractLauncherIcon::QUIRK_DESAT, is_overlay_open);
2628
 
    it->SetQuirk(AbstractLauncherIcon::QUIRK_PRESENTED, false);
 
2634
    it->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, is_overlay_open);
 
2635
    it->SetQuirk(AbstractLauncherIcon::Quirk::PRESENTED, false);
2629
2636
  }
2630
2637
 
2631
2638
  DndHoveredIconReset();
2638
2645
 
2639
2646
  if (_steal_drag && _dnd_hovered_icon)
2640
2647
  {
2641
 
    _dnd_hovered_icon->SetQuirk(AbstractLauncherIcon::QUIRK_VISIBLE, false);
 
2648
    _dnd_hovered_icon->SetQuirk(AbstractLauncherIcon::Quirk::VISIBLE, false);
2642
2649
    _dnd_hovered_icon->remove.emit(_dnd_hovered_icon);
2643
2650
  }
2644
2651
 
2695
2702
      for (auto it : *_model)
2696
2703
      {
2697
2704
        if (it->ShouldHighlightOnDrag(_dnd_data))
2698
 
          it->SetQuirk(AbstractLauncherIcon::QUIRK_DESAT, false);
 
2705
          it->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, false);
2699
2706
        else
2700
 
          it->SetQuirk(AbstractLauncherIcon::QUIRK_DESAT, true);
 
2707
          it->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, true);
2701
2708
      }
2702
2709
    }
2703
2710
  }
2726
2733
  bool hovered_icon_is_appropriate = false;
2727
2734
  if (hovered_icon)
2728
2735
  {
2729
 
    if (hovered_icon->GetIconType() == AbstractLauncherIcon::TYPE_TRASH)
 
2736
    if (hovered_icon->GetIconType() == AbstractLauncherIcon::IconType::TRASH)
2730
2737
      _steal_drag = false;
2731
2738
 
2732
 
    if (hovered_icon->GetIconType() == AbstractLauncherIcon::TYPE_APPLICATION || hovered_icon->GetIconType() == AbstractLauncherIcon::TYPE_EXPO)
 
2739
    if (hovered_icon->GetIconType() == AbstractLauncherIcon::IconType::APPLICATION || hovered_icon->GetIconType() == AbstractLauncherIcon::IconType::EXPO)
2733
2740
      hovered_icon_is_appropriate = true;
2734
2741
  }
2735
2742
 
2753
2760
        }
2754
2761
        else
2755
2762
        {
2756
 
          _dnd_hovered_icon->SetQuirk(AbstractLauncherIcon::QUIRK_VISIBLE, false);
 
2763
          _dnd_hovered_icon->SetQuirk(AbstractLauncherIcon::Quirk::VISIBLE, false);
2757
2764
          _dnd_hovered_icon->remove.emit(_dnd_hovered_icon);
2758
2765
          _dnd_hovered_icon = nullptr;
2759
2766
        }