30
30
#include <debug_p.h>
31
31
#include <unity2dpanel.h>
37
35
#include <QDBusConnection>
38
36
#include <QDBusServiceWatcher>
40
static const char* LAUNCHER_DCONF_SCHEMA = "com.canonical.Unity2d.Launcher";
42
38
VisibilityController::VisibilityController(Unity2dPanel* panel)
45
, m_dconf_launcher(new QConf(LAUNCHER_DCONF_SCHEMA))
46
41
, m_dbusWatcher(new QDBusServiceWatcher(this))
48
43
m_dbusWatcher->setConnection(QDBusConnection::sessionBus());
49
44
m_dbusWatcher->setWatchMode(QDBusServiceWatcher::WatchForUnregistration);
51
connect(m_dconf_launcher, SIGNAL(hideModeChanged(int)), SLOT(update()));
52
connect(m_panel, SIGNAL(useStrutChanged(bool)), SLOT(update()));
46
connect(&launcher2dConfiguration(), SIGNAL(hideModeChanged(int)), SLOT(update()));
53
47
connect(m_panel, SIGNAL(manualSlidingChanged(bool)), SLOT(update()));
54
48
connect(m_dbusWatcher, SIGNAL(serviceUnregistered(const QString&)), SLOT(slotServiceUnregistered(const QString&)));
58
52
VisibilityController::~VisibilityController()
60
delete m_dconf_launcher;
63
void VisibilityController::update()
56
void VisibilityController::update(UpdateReason reason)
65
58
if (!m_forceVisibleCountHash.isEmpty()) {
68
AutoHideMode mode = AutoHideMode(m_dconf_launcher->property("hideMode").toInt());
61
AutoHideMode mode = AutoHideMode(launcher2dConfiguration().property("hideMode").toInt());
72
/* Do not use any hiding controller if the panel is either:
74
- locked in place (using struts)
76
if (!m_panel->manualSliding() && !m_panel->useStrut()) {
65
/* Do not use any hiding controller if the panel is being slid manually */
66
if (!m_panel->manualSliding()) {
69
m_panel->setUseStrut(true);
73
m_panel->setUseStrut(false);
81
74
setBehavior(new AutoHideBehavior(m_panel));
77
m_panel->setUseStrut(false);
84
78
setBehavior(new IntelliHideBehavior(m_panel));
79
if (reason == UpdateFromForceVisibilityEnded && !m_panel->geometry().contains(QCursor::pos())) {
80
// The first thing IntelliHideBehavior does is checking if there is
81
// a window behind the panel, and if there is one, hide the panel immediately
82
// This is correct for some cases, but in the case we come from an update because the
83
// panel is not forced visible anymore and the mouse is not in the panel,
84
// i.e. the launcher was visible and the user clicked in an action of the tile menu,
85
// we should still give the user the wait 1 second before hiding behaviour.
86
// To achieve this we tell the behaviour controller to show the panel
87
// and simulate a mouse leave on the panel to start the hiding timer
88
QMetaObject::invokeMethod(m_behavior.data(), "showPanel");
89
QEvent e(QEvent::Leave);
90
QCoreApplication::sendEvent(m_panel, &e);