~3v1n0/unity/overlay-border-scale

« back to all changes in this revision

Viewing changes to plugins/unityshell/src/LauncherHideMachine.cpp

  • Committer: Daniel van Vugt
  • Date: 2012-03-14 06:24:18 UTC
  • mfrom: (2108 unity)
  • mto: This revision was merged to the branch mainline in revision 2146.
  • Revision ID: daniel.van.vugt@canonical.com-20120314062418-nprucpbr0m7qky5e
MergedĀ latestĀ lp:unity

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
  _mode  = HIDE_NEVER;
36
36
  _quirks = DEFAULT;
37
37
  _should_hide = false;
38
 
  _show_on_edge = true;
39
38
 
40
39
  _latest_emit_should_hide = false;
41
40
  _hide_changed_emit_handle = 0;
 
41
  reveal_progress = 0;
42
42
 
43
43
  _hide_delay_handle = 0;
44
44
  _hide_delay_timeout_length = 750;
 
45
 
 
46
  decaymulator_ = unity::ui::Decaymulator::Ptr(new unity::ui::Decaymulator());
 
47
  decaymulator_->value.changed.connect([&](int value) -> void { reveal_progress = (float)value / (float)reveal_pressure; });
 
48
 
 
49
  edge_decay_rate.changed.connect(sigc::mem_fun (this, &LauncherHideMachine::OnDecayRateChanged));
 
50
}
 
51
 
 
52
void LauncherHideMachine::OnDecayRateChanged(int value)
 
53
{
 
54
  decaymulator_->rate_of_decay = value;  
45
55
}
46
56
 
47
57
LauncherHideMachine::~LauncherHideMachine()
59
69
}
60
70
 
61
71
void
 
72
LauncherHideMachine::AddRevealPressure(int pressure)
 
73
{
 
74
  decaymulator_->value = decaymulator_->value + pressure;
 
75
 
 
76
  if (decaymulator_->value > reveal_pressure)
 
77
  {
 
78
    SetQuirk(REVEAL_PRESSURE_PASS, true);
 
79
    SetQuirk(MOUSE_MOVE_POST_REVEAL, true);
 
80
    decaymulator_->value = 0;
 
81
  }
 
82
}
 
83
 
 
84
void
62
85
LauncherHideMachine::SetShouldHide(bool value, bool skip_delay)
63
86
{
64
87
  if (_should_hide == value)
88
111
    EXTERNAL_DND_ACTIVE    = 1 << 5, 32  #VISIBLE_REQUIRED
89
112
    INTERNAL_DND_ACTIVE    = 1 << 6, 64  #VISIBLE_REQUIRED
90
113
    TRIGGER_BUTTON_SHOW    = 1 << 7, 128 #VISIBLE_REQUIRED
91
 
    ANY_WINDOW_UNDER       = 1 << 8, 256
92
 
    ACTIVE_WINDOW_UNDER    = 1 << 9, 512
93
114
    DND_PUSHED_OFF         = 1 << 10, 1024
94
115
    MOUSE_MOVE_POST_REVEAL = 1 << 11, 2k
95
116
    VERTICAL_SLIDE_ACTIVE  = 1 << 12, 4k  #VISIBLE_REQUIRED
99
120
    SCALE_ACTIVE           = 1 << 16, 64k  #VISIBLE_REQUIRED
100
121
    EXPO_ACTIVE            = 1 << 17, 128k #VISIBLE_REQUIRED
101
122
    MT_DRAG_OUT            = 1 << 18, 256k #VISIBLE_REQUIRED
102
 
    MOUSE_OVER_ACTIVE_EDGE = 1 << 19, 512k
103
123
    LAUNCHER_PULSE         = 1 << 20, 1M   #VISIBLE_REQUIRED
104
124
    LOCK_HIDE              = 1 << 21, 2M
105
125
*/
140
160
    bool hide_for_window = false;
141
161
    if (_mode == AUTOHIDE)
142
162
      hide_for_window = true;
143
 
    else if (_mode == DODGE_WINDOWS)
144
 
      hide_for_window = GetQuirk(ANY_WINDOW_UNDER);
145
 
    else if (_mode == DODGE_ACTIVE_WINDOW)
146
 
      hide_for_window = GetQuirk(ACTIVE_WINDOW_UNDER);
147
163
 
148
164
    // if we activated AND we would hide because of a window, go ahead and do it
149
165
    if (!_should_hide && GetQuirk(LAST_ACTION_ACTIVATE) && hide_for_window)
156
172
    HideQuirk _should_show_quirk;
157
173
    if (GetQuirk(LAUNCHER_HIDDEN))
158
174
    {
159
 
      _should_show_quirk = (HideQuirk)(VISIBLE_REQUIRED);
160
 
 
161
 
      if (_show_on_edge)
162
 
        _should_show_quirk = (HideQuirk)(_should_show_quirk | MOUSE_OVER_ACTIVE_EDGE);
163
 
 
 
175
      _should_show_quirk = (HideQuirk) ((VISIBLE_REQUIRED) | REVEAL_PRESSURE_PASS);
164
176
    }
165
177
    else
166
178
    {
168
180
      // mouse position over launcher is only taken into account if we move it after the revealing state
169
181
      if (GetQuirk(MOUSE_MOVE_POST_REVEAL))
170
182
        _should_show_quirk = (HideQuirk)(_should_show_quirk | MOUSE_OVER_LAUNCHER);
171
 
 
172
 
      if (_show_on_edge)
173
 
        _should_show_quirk = (HideQuirk)(_should_show_quirk | MOUSE_OVER_ACTIVE_EDGE);
174
183
    }
175
184
 
176
185
    if (GetQuirk(_should_show_quirk))
199
208
}
200
209
 
201
210
LauncherHideMachine::HideMode
202
 
LauncherHideMachine::GetMode()
 
211
LauncherHideMachine::GetMode() const
203
212
{
204
213
  return _mode;
205
214
}
206
215
 
207
 
#define SKIP_DELAY_QUIRK (EXTERNAL_DND_ACTIVE | DND_PUSHED_OFF | ACTIVE_WINDOW_UNDER | \
208
 
ANY_WINDOW_UNDER | EXPO_ACTIVE | SCALE_ACTIVE | MT_DRAG_OUT | TRIGGER_BUTTON_SHOW)
 
216
#define SKIP_DELAY_QUIRK (EXTERNAL_DND_ACTIVE | DND_PUSHED_OFF | EXPO_ACTIVE | SCALE_ACTIVE | MT_DRAG_OUT | TRIGGER_BUTTON_SHOW)
209
217
 
210
218
void
211
219
LauncherHideMachine::SetQuirk(LauncherHideMachine::HideQuirk quirk, bool active)
229
237
}
230
238
 
231
239
bool
232
 
LauncherHideMachine::GetQuirk(LauncherHideMachine::HideQuirk quirk, bool allow_partial)
 
240
LauncherHideMachine::GetQuirk(LauncherHideMachine::HideQuirk quirk, bool allow_partial) const
233
241
{
234
242
  if (allow_partial)
235
243
    return _quirks & quirk;
237
245
}
238
246
 
239
247
bool
240
 
LauncherHideMachine::ShouldHide()
 
248
LauncherHideMachine::ShouldHide() const
241
249
{
242
250
  return _should_hide;
243
251
}
244
252
 
245
 
void
246
 
LauncherHideMachine::SetShowOnEdge(bool value)
247
 
{
248
 
  if (value == _show_on_edge)
249
 
    return;
250
 
 
251
 
  _show_on_edge = value;
252
 
 
253
 
  LOG_DEBUG(logger) << "Shows on edge: " << _show_on_edge;
254
 
}
255
 
 
256
 
bool
257
 
LauncherHideMachine::GetShowOnEdge()
258
 
{
259
 
  return _show_on_edge;
260
 
}
261
 
 
262
253
gboolean
263
254
LauncherHideMachine::OnHideDelayTimeout(gpointer data)
264
255
{
285
276
}
286
277
 
287
278
std::string
288
 
LauncherHideMachine::DebugHideQuirks()
 
279
LauncherHideMachine::DebugHideQuirks() const
289
280
{
290
281
  // Although I do wonder why we are returning a string representation
291
282
  // of the enum value as an integer anyway.