70
71
int LauncherIcon::_current_theme_is_mono = -1;
71
72
GtkIconTheme* LauncherIcon::_unity_theme = NULL;
72
gboolean LauncherIcon::_skip_tooltip_delay = false;
74
LauncherIcon::LauncherIcon(Launcher* launcher)
76
, _menuclient_dynamic_quicklist(nullptr)
77
, _has_visible_window(false)
74
LauncherIcon::LauncherIcon()
75
: _menuclient_dynamic_quicklist(nullptr)
78
76
, _quicklist_is_initialized(false)
79
77
, _remote_urgent(false)
80
78
, _present_urgency(0)
82
80
, _center_stabilize_handle(0)
83
81
, _present_time_handle(0)
84
82
, _time_delay_handle(0)
85
, _tooltip_delay_handle(0)
87
83
, _sort_priority(0)
88
84
, _background_color(nux::color::White)
89
85
, _glow_color(nux::color::White)
91
87
, _icon_type(TYPE_NONE)
89
_has_visible_window.resize(max_num_monitors);
90
_center.resize(max_num_monitors);
91
_saved_center.resize(max_num_monitors);
92
_last_stable.resize(max_num_monitors);
93
_parent_geo.resize(max_num_monitors);
94
transform_map.resize(max_num_monitors);
93
96
for (int i = 0; i < QUIRK_LAST; i++)
95
98
_quirks[i] = false;
141
144
g_source_remove(_time_delay_handle);
142
145
_time_delay_handle = 0;
144
if (_tooltip_delay_handle)
145
g_source_remove(_tooltip_delay_handle);
146
_tooltip_delay_handle = 0;
147
147
// clean up the whole signal-callback mess
148
148
if (needs_redraw_connection.connected())
149
149
needs_redraw_connection.disconnect();
183
183
LauncherIcon::AddProperties(GVariantBuilder* builder)
185
185
unity::variant::BuilderWrapper(builder)
189
.add("related-windows", _related_windows)
186
.add("x", _center[0].x)
187
.add("y", _center[0].y)
188
.add("z", _center[0].z)
189
.add("related-windows", (int)Windows().size())
190
190
.add("icon-type", _icon_type)
191
191
.add("tooltip-text", tooltip_text().c_str())
192
192
.add("sort-priority", _sort_priority)
482
LauncherIcon::SetSkipTooltipDelay(gboolean skip_tooltip_delay)
484
_skip_tooltip_delay = skip_tooltip_delay;
488
LauncherIcon::OnTooltipTimeout(gpointer data)
490
LauncherIcon* self = (LauncherIcon*) data;
492
if (!self->_launcher)
495
nux::Geometry geo = self->_launcher->GetAbsoluteGeometry();
496
int tip_x = geo.x + geo.width + 1;
497
int tip_y = geo.y + self->_center.y;
499
self->_tooltip->ShowTooltipWithTipAt(tip_x, tip_y);
501
if (!self->_quicklist->IsVisible())
486
LauncherIcon::ShowTooltip()
488
if (_quicklist->IsVisible())
493
if (_last_monitor >= 0)
503
self->_tooltip->ShowWindow(!self->tooltip_text().empty());
504
_skip_tooltip_delay = TRUE;
495
nux::Geometry geo = _parent_geo[_last_monitor];
496
tip_x = geo.x + geo.width + 1;
497
tip_y = geo.y + _center[_last_monitor].y;
507
self->_tooltip_delay_handle = 0;
500
_tooltip->ShowTooltipWithTipAt(tip_x, tip_y);
501
_tooltip->ShowWindow(!tooltip_text().empty());
512
LauncherIcon::RecvMouseEnter()
505
LauncherIcon::RecvMouseEnter(int monitor)
507
_last_monitor = monitor;
514
508
if (QuicklistManager::Default()->Current())
516
510
// A quicklist is active
520
if (!_skip_tooltip_delay)
521
_tooltip_delay_handle = g_timeout_add(500, &LauncherIcon::OnTooltipTimeout, this);
523
OnTooltipTimeout(this);
526
void LauncherIcon::RecvMouseLeave()
517
void LauncherIcon::RecvMouseLeave(int monitor)
528
if (_tooltip_delay_handle)
529
g_source_remove(_tooltip_delay_handle);
530
_tooltip_delay_handle = 0;
532
521
_tooltip->ShowWindow(false);
535
bool LauncherIcon::OpenQuicklist(bool default_to_first_item)
524
bool LauncherIcon::OpenQuicklist(bool default_to_first_item, int monitor)
537
526
std::list<DbusmenuMenuitem*> menus = Menus();
539
528
if (menus.empty())
542
if (_tooltip_delay_handle)
543
g_source_remove(_tooltip_delay_handle);
544
_tooltip_delay_handle = 0;
545
_skip_tooltip_delay = false;
547
531
_tooltip->ShowWindow(false);
548
532
_quicklist->RemoveAllMenuItem();
582
566
if (default_to_first_item)
583
567
_quicklist->DefaultToFirstItem();
588
nux::Geometry geo = _launcher->GetAbsoluteGeometry();
589
tip_x = geo.x + geo.width + 1;
590
tip_y = geo.y + _center.y;
571
if (_last_monitor >= 0)
572
monitor = _last_monitor;
577
nux::Geometry geo = _parent_geo[monitor];
578
int tip_x = geo.x + geo.width + 1;
579
int tip_y = geo.y + _center[monitor].y;
598
581
auto win_manager = WindowManager::Default();
620
void LauncherIcon::RecvMouseDown(int button)
603
void LauncherIcon::RecvMouseDown(int button, int monitor)
626
void LauncherIcon::RecvMouseUp(int button)
609
void LauncherIcon::RecvMouseUp(int button, int monitor)
644
629
void LauncherIcon::HideTooltip()
646
if (_tooltip_delay_handle)
647
g_source_remove(_tooltip_delay_handle);
648
_tooltip_delay_handle = 0;
649
_skip_tooltip_delay = false;
651
631
_tooltip->ShowWindow(false);
657
637
LauncherIcon* self = (LauncherIcon*)data;
659
if (self->_last_stable != self->_center)
639
if (!std::equal(self->_center.begin(), self->_center.end(), self->_last_stable.begin()))
661
641
self->OnCenterStabilized(self->_center);
662
642
self->_last_stable = self->_center;
670
LauncherIcon::SetCenter(nux::Point3 center)
650
LauncherIcon::SetCenter(nux::Point3 center, int monitor, nux::Geometry geo)
652
_center[monitor] = center;
653
_parent_geo[monitor] = geo;
655
if (monitor == _last_monitor)
677
nux::Geometry geo = _launcher->GetAbsoluteGeometry();
678
658
tip_x = geo.x + geo.width + 1;
679
tip_y = geo.y + _center.y;
659
tip_y = geo.y + _center[monitor].y;
687
if (_quicklist->IsVisible())
688
QuicklistManager::Default()->ShowQuicklist(_quicklist, tip_x, tip_y);
689
else if (_tooltip->IsVisible())
690
_tooltip->ShowTooltipWithTipAt(tip_x, tip_y);
661
if (_quicklist->IsVisible())
662
QuicklistManager::Default()->ShowQuicklist(_quicklist, tip_x, tip_y);
663
else if (_tooltip->IsVisible())
664
_tooltip->ShowTooltipWithTipAt(tip_x, tip_y);
692
667
if (_center_stabilize_handle)
693
668
g_source_remove(_center_stabilize_handle);
699
LauncherIcon::GetCenter()
674
LauncherIcon::GetCenter(int monitor)
676
return _center[monitor];
680
LauncherIcon::GetSavedCenter(int monitor)
682
return _saved_center[monitor];
685
std::vector<nux::Point3> LauncherIcon::GetCenters()
712
LauncherIcon::SetHasWindowOnViewport(bool val)
698
LauncherIcon::SetWindowVisibleOnMonitor(bool val, int monitor)
714
if (_has_visible_window == val)
700
if (_has_visible_window[monitor] == val)
717
_has_visible_window = val;
703
_has_visible_window[monitor] = val;
718
704
needs_redraw.emit(this);
818
794
if (_quirks[quirk] == value)
821
if (quirk == QUIRK_PULSE_ONCE)
822
_launcher->HideMachine()->SetQuirk(LauncherHideMachine::LAUNCHER_PULSE, value);
824
797
_quirks[quirk] = value;
825
798
if (quirk == QUIRK_VISIBLE)
826
Launcher::SetTimeStruct(&(_quirk_times[quirk]), &(_quirk_times[quirk]), ANIM_DURATION_SHORT);
799
TimeUtil::SetTimeStruct(&(_quirk_times[quirk]), &(_quirk_times[quirk]), ANIM_DURATION_SHORT);
828
801
clock_gettime(CLOCK_MONOTONIC, &(_quirk_times[quirk]));
829
802
needs_redraw.emit(this);
951
918
std::vector<nux::Vector4> &
952
LauncherIcon::GetTransform(TransformIndex index)
919
LauncherIcon::GetTransform(TransformIndex index, int monitor)
954
auto iter = transform_map.find(index);
955
if (iter == transform_map.end())
921
auto iter = transform_map[monitor].find(index);
922
if (iter == transform_map[monitor].end())
957
auto iter2 = transform_map.insert(std::map<TransformIndex, std::vector<nux::Vector4> >::value_type(index, std::vector<nux::Vector4>(4)));
924
auto iter2 = transform_map[monitor].insert(std::map<TransformIndex, std::vector<nux::Vector4> >::value_type(index, std::vector<nux::Vector4>(4)));
958
925
return iter2.first->second;