28
28
#include <Nux/TimerProc.h>
29
29
#include <NuxGraphics/IOpenGLAsmShader.h>
31
#include "PointerBarrier.h"
31
32
#include "AbstractIconRenderer.h"
32
33
#include "BackgroundEffectHelper.h"
33
34
#include "DNDCollectionWindow.h"
34
35
#include "DndData.h"
35
36
#include "GeisAdapter.h"
36
37
#include "Introspectable.h"
38
#include "LauncherOptions.h"
37
39
#include "LauncherDragWindow.h"
38
40
#include "LauncherHideMachine.h"
39
41
#include "LauncherHoverMachine.h"
40
42
#include "UBusWrapper.h"
42
#define ANIM_DURATION_SHORT_SHORT 100
43
#define ANIM_DURATION_SHORT 125
44
#define ANIM_DURATION 200
45
#define ANIM_DURATION_LONG 350
47
#define SUPER_TAP_DURATION 250
48
#define SHORTCUTS_SHOWN_DELAY 750
49
#define START_DRAGICON_DURATION 250
50
#define BEFORE_HIDE_LAUNCHER_ON_SUPER_DURATION 1000
52
#define IGNORE_REPEAT_SHORTCUT_DURATION 250
54
#define MAX_SUPERKEY_LABELS 10
49
class AbstractLauncherIcon;
63
50
class LauncherModel;
65
52
class Launcher : public unity::debug::Introspectable, public nux::View
67
54
NUX_DECLARE_OBJECT_TYPE(Launcher, nux::View);
72
LAUNCHER_HIDE_AUTOHIDE,
73
LAUNCHER_HIDE_DODGE_WINDOWS,
74
LAUNCHER_HIDE_DODGE_ACTIVE_WINDOW,
79
LAUNCH_ANIMATION_NONE,
80
LAUNCH_ANIMATION_PULSE,
81
LAUNCH_ANIMATION_BLINK,
86
URGENT_ANIMATION_NONE,
87
URGENT_ANIMATION_PULSE,
88
URGENT_ANIMATION_WIGGLE,
103
BACKLIGHT_ALWAYS_OFF,
104
BACKLIGHT_EDGE_TOGGLE,
105
BACKLIGHT_NORMAL_EDGE_TOGGLE
108
57
Launcher(nux::BaseWindow* parent, NUX_FILE_LINE_PROTO);
111
60
nux::Property<Display*> display;
61
nux::Property<int> monitor;
62
nux::Property<Options::Ptr> options;
113
64
virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
114
65
virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
115
66
virtual void PostDraw(nux::GraphicsEngine& GfxContext, bool force_draw);
117
LauncherIcon* GetSelectedMenuIcon();
68
AbstractLauncherIcon::Ptr GetSelectedMenuIcon() const;
119
70
void SetIconSize(int tile_size, int icon_size);
120
void SetBackgroundAlpha(float background_alpha);
122
72
LauncherHideMachine* HideMachine() { return _hide_machine; }
130
return _hide_machine->GetShowOnEdge();
79
void ForceReveal(bool force);
80
void ShowShortcuts(bool show);
133
82
void SetModel(LauncherModel* model);
134
LauncherModel* GetModel();
136
void SetFloating(bool floating);
138
void SetHideMode(LauncherHideMode hidemode);
139
LauncherHideMode GetHideMode();
83
LauncherModel* GetModel() const;
141
85
void StartKeyShowLauncher();
142
86
void EndKeyShowLauncher();
88
void EnsureIconOnScreen(AbstractLauncherIcon::Ptr icon);
144
90
void SetBacklightMode(BacklightMode mode);
145
BacklightMode GetBacklightMode();
146
bool IsBackLightModeToggles();
148
void SetLaunchAnimation(LaunchAnimation animation);
149
LaunchAnimation GetLaunchAnimation();
151
void SetUrgentAnimation(UrgentAnimation animation);
152
UrgentAnimation GetUrgentAnimation();
154
void SetAutoHideAnimation(AutoHideAnimation animation);
155
AutoHideAnimation GetAutoHideAnimation();
157
void EdgeRevealTriggered(int x, int y);
159
gboolean CheckSuperShortcutPressed(Display *x_display, unsigned int key_sym, unsigned long key_code, unsigned long key_state, char* key_string);
160
void SetLatestShortcut(guint64 shortcut);
162
nux::BaseWindow* GetParent()
91
BacklightMode GetBacklightMode() const;
92
bool IsBackLightModeToggles() const;
94
nux::BaseWindow* GetParent() const
167
static void SetTimeStruct(struct timespec* timer, struct timespec* sister = 0, int sister_relation = 0);
169
99
virtual void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
170
100
virtual void RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
171
101
virtual void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
173
103
virtual void RecvMouseLeave(int x, int y, unsigned long button_flags, unsigned long key_flags);
174
104
virtual void RecvMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
175
105
virtual void RecvMouseWheel(int x, int y, int wheel_delta, unsigned long button_flags, unsigned long key_flags);
176
virtual void RecvMouseDownOutsideArea(int x, int y, unsigned long button_flags, unsigned long key_flags);
178
virtual void RecvKeyPressed(unsigned long eventType , /*event type*/
179
unsigned long keysym , /*event keysym*/
180
unsigned long state , /*event state*/
181
const char* character , /*character*/
182
unsigned short keyCount /*key repeat count*/);
184
107
virtual void RecvQuicklistOpened(QuicklistView* quicklist);
185
108
virtual void RecvQuicklistClosed(QuicklistView* quicklist);
187
void startKeyNavMode();
188
void leaveKeyNavMode(bool preserve_focus = true);
190
void exitKeyNavMode(); // Connected to signal OnEndFocus
195
void CheckWindowOverLauncher();
196
void EnableCheckWindowOverLauncher(gboolean enabled);
198
sigc::signal<void, char*, LauncherIcon*> launcher_addrequest;
199
sigc::signal<void, char*, LauncherIcon*, char*, char*> launcher_addrequest_special;
200
sigc::signal<void, LauncherIcon*> launcher_removerequest;
110
int GetMouseX() const;
111
int GetMouseY() const;
115
sigc::signal<void, char*, AbstractLauncherIcon::Ptr> launcher_addrequest;
116
sigc::signal<void, std::string const&, AbstractLauncherIcon::Ptr, std::string const&, std::string const&> launcher_addrequest_special;
117
sigc::signal<void, AbstractLauncherIcon::Ptr> launcher_removerequest;
201
118
sigc::signal<void> selection_change;
202
119
sigc::signal<void> hidden_changed;
205
121
virtual bool InspectKeyEvent(unsigned int eventType,
206
122
unsigned int keysym,
207
123
const char* character);
209
void SelectPreviousIcon();
210
void SelectNextIcon();
125
void EnterKeyNavMode();
126
void ExitKeyNavMode();
127
bool IsInKeyNavMode() const;
212
void KeySwitcherActivate();
213
void KeySwitcherTerminate();
214
bool KeySwitcherIsActive();
215
void KeySwitcherNext();
216
void KeySwitcherPrevious();
129
static const int ANIM_DURATION_SHORT;
219
132
// Introspectable methods
260
179
void OnDragUpdate(GeisAdapter::GeisDragData* data);
261
180
void OnDragFinish(GeisAdapter::GeisDragData* data);
182
void OnPointerBarrierEvent(ui::PointerBarrierWrapper* owner, ui::BarrierEvent::Ptr event);
263
184
void OnPluginStateChanged();
265
void OnViewPortSwitchStarted();
266
void OnViewPortSwitchEnded();
186
void OnSelectionChanged(AbstractLauncherIcon::Ptr selection);
268
188
static gboolean AnimationTimeout(gpointer data);
269
static gboolean SuperShowLauncherTimeout(gpointer data);
270
static gboolean SuperHideLauncherTimeout(gpointer data);
271
static gboolean SuperShowShortcutsTimeout(gpointer data);
272
189
static gboolean StrutHack(gpointer data);
273
static gboolean MoveFocusToKeyNavModeTimeout(gpointer data);
274
190
static gboolean StartIconDragTimeout(gpointer data);
275
static gboolean ResetRepeatShorcutTimeout(gpointer data);
277
192
void SetMousePosition(int x, int y);
279
194
void SetStateMouseOverLauncher(bool over_launcher);
280
void SetStateKeyNav(bool keynav_activated);
282
bool MouseBeyondDragThreshold();
196
bool MouseBeyondDragThreshold() const;
284
198
void OnDragWindowAnimCompleted();
286
bool IconNeedsAnimation(LauncherIcon* icon, struct timespec const& current);
287
bool IconDrawEdgeOnly(LauncherIcon* icon);
288
bool AnimationInProgress();
200
bool IconNeedsAnimation(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const;
201
bool IconDrawEdgeOnly(AbstractLauncherIcon::Ptr icon) const;
202
bool AnimationInProgress() const;
290
204
void SetActionState(LauncherActionState actionstate);
291
LauncherActionState GetActionState();
205
LauncherActionState GetActionState() const;
293
207
void EnsureAnimation();
294
208
void EnsureScrollTimer();
302
216
static gboolean OnScrollTimeout(gpointer data);
303
217
static gboolean OnUpdateDragManagerTimeout(gpointer data);
305
float DnDStartProgress(struct timespec const& current);
306
float DnDExitProgress(struct timespec const& current);
307
float GetHoverProgress(struct timespec const& current);
308
float AutohideProgress(struct timespec const& current);
309
float DragThresholdProgress(struct timespec const& current);
310
float DragHideProgress(struct timespec const& current);
311
float DragOutProgress(struct timespec const& current);
312
float IconDesatValue(LauncherIcon* icon, struct timespec const& current);
313
float IconPresentProgress(LauncherIcon* icon, struct timespec const& current);
314
float IconUrgentProgress(LauncherIcon* icon, struct timespec const& current);
315
float IconShimmerProgress(LauncherIcon* icon, struct timespec const& current);
316
float IconUrgentPulseValue(LauncherIcon* icon, struct timespec const& current);
317
float IconPulseOnceValue(LauncherIcon *icon, struct timespec const ¤t);
318
float IconUrgentWiggleValue(LauncherIcon* icon, struct timespec const& current);
319
float IconStartingBlinkValue(LauncherIcon* icon, struct timespec const& current);
320
float IconStartingPulseValue(LauncherIcon* icon, struct timespec const& current);
321
float IconBackgroundIntensity(LauncherIcon* icon, struct timespec const& current);
322
float IconProgressBias(LauncherIcon* icon, struct timespec const& current);
323
float IconDropDimValue(LauncherIcon* icon, struct timespec const& current);
324
float IconCenterTransitionProgress(LauncherIcon* icon, struct timespec const& current);
219
float DnDStartProgress(struct timespec const& current) const;
220
float DnDExitProgress(struct timespec const& current) const;
221
float GetHoverProgress(struct timespec const& current) const;
222
float AutohideProgress(struct timespec const& current) const;
223
float DragThresholdProgress(struct timespec const& current) const;
224
float DragHideProgress(struct timespec const& current) const;
225
float DragOutProgress(struct timespec const& current) const;
226
float IconDesatValue(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const;
227
float IconPresentProgress(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const;
228
float IconUrgentProgress(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const;
229
float IconShimmerProgress(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const;
230
float IconUrgentPulseValue(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const;
231
float IconPulseOnceValue(AbstractLauncherIcon::Ptr icon, struct timespec const ¤t) const;
232
float IconUrgentWiggleValue(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const;
233
float IconStartingBlinkValue(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const;
234
float IconStartingPulseValue(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const;
235
float IconBackgroundIntensity(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const;
236
float IconProgressBias(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const;
237
float IconDropDimValue(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const;
238
float IconCenterTransitionProgress(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const;
239
float IconVisibleProgress(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const;
326
241
void SetHover(bool hovered);
327
242
void SetHidden(bool hidden);
342
258
struct timespec const& current);
344
260
void RenderArgs(std::list<ui::RenderArg> &launcher_args,
345
nux::Geometry& box_geo, float* launcher_alpha);
261
nux::Geometry& box_geo, float* launcher_alpha, nux::Geometry const& parent_abs_geo);
347
void OnIconAdded(LauncherIcon* icon);
348
void OnIconRemoved(LauncherIcon* icon);
263
void OnIconAdded(AbstractLauncherIcon::Ptr icon);
264
void OnIconRemoved(AbstractLauncherIcon::Ptr icon);
349
265
void OnOrderChanged();
351
void OnIconNeedsRedraw(AbstractLauncherIcon* icon);
267
void OnIconNeedsRedraw(AbstractLauncherIcon::Ptr icon);
353
void OnPlaceViewHidden(GVariant* data);
354
void OnPlaceViewShown(GVariant* data);
269
void OnOverlayHidden(GVariant* data);
270
void OnOverlayShown(GVariant* data);
356
272
void DesaturateIcons();
357
273
void SaturateIcons();
363
279
void OnActionDone(GVariant* data);
365
void RenderIconToTexture(nux::GraphicsEngine& GfxContext, LauncherIcon* icon, nux::ObjectPtr<nux::IOpenGLBaseTexture> texture);
281
void RenderIconToTexture(nux::GraphicsEngine& GfxContext, AbstractLauncherIcon::Ptr icon, nux::ObjectPtr<nux::IOpenGLBaseTexture> texture);
367
LauncherIcon* MouseIconIntersection(int x, int y);
283
AbstractLauncherIcon::Ptr MouseIconIntersection(int x, int y);
368
284
void EventLogic();
369
285
void MouseDownLogic(int x, int y, unsigned long button_flags, unsigned long key_flags);
370
286
void MouseUpLogic(int x, int y, unsigned long button_flags, unsigned long key_flags);
372
288
void StartIconDragRequest(int x, int y);
373
void StartIconDrag(LauncherIcon* icon);
289
void StartIconDrag(AbstractLauncherIcon::Ptr icon);
374
290
void EndIconDrag();
375
291
void UpdateDragWindowPosition(int x, int y);
377
float GetAutohidePositionMin();
378
float GetAutohidePositionMax();
293
float GetAutohidePositionMin() const;
294
float GetAutohidePositionMax() const;
380
virtual void PreLayoutManagement();
381
296
virtual long PostLayoutManagement(long LayoutResult);
382
virtual void PositionChildLayout(float offsetX, float offsetY);
384
298
void SetOffscreenRenderTarget(nux::ObjectPtr<nux::IOpenGLBaseTexture> texture);
385
299
void RestoreSystemRenderTarget();
387
gboolean TapOnSuper();
389
301
void OnDisplayChanged(Display* display);
390
302
void OnDNDDataCollected(const std::list<char*>& mimes);
393
305
void DndHoveredIconReset();
395
307
nux::HLayout* m_Layout;
396
int m_ContentOffsetY;
398
309
// used by keyboard/a11y-navigation
399
LauncherIcon* _current_icon;
400
LauncherIcon* m_ActiveTooltipIcon;
401
LauncherIcon* _icon_under_mouse;
402
LauncherIcon* _icon_mouse_down;
403
LauncherIcon* _drag_icon;
405
int _current_icon_index;
406
int _last_icon_index;
310
AbstractLauncherIcon::Ptr _icon_under_mouse;
311
AbstractLauncherIcon::Ptr _icon_mouse_down;
312
AbstractLauncherIcon::Ptr _drag_icon;
408
314
QuicklistView* _active_quicklist;
413
318
bool _scroll_limit_reached;
414
319
bool _render_drag_window;
415
bool _check_window_over_launcher;
417
321
bool _shortcuts_shown;
418
bool _keynav_activated;
419
bool _key_switcher_activated;
420
guint64 _latest_shortcut;
422
323
BacklightMode _backlight_mode;
450
352
int _drag_out_id;
451
353
float _drag_out_delta_x;
452
354
float _background_alpha;
355
float _last_reveal_progress;
457
357
guint _autoscroll_handle;
458
guint _focus_keynav_handle;
459
guint _super_show_launcher_handle;
460
guint _super_hide_launcher_handle;
461
guint _super_show_shortcuts_handle;
462
358
guint _start_dragicon_handle;
463
359
guint _dnd_check_handle;
464
guint _ignore_repeat_shortcut_handle;
360
guint _strut_hack_handle;
466
362
nux::Point2 _mouse_position;
467
nux::Point2 _bfb_mouse_position;
468
nux::AbstractPaintLayer* m_BackgroundLayer;
469
363
nux::BaseWindow* _parent;
470
364
LauncherModel* _model;
471
365
LauncherDragWindow* _drag_window;