Improve variable names in InputDeviceHandler

This commit is contained in:
Vlad Zahorodnii 2021-11-29 18:33:08 +02:00
parent f097440eb4
commit d957e99365
3 changed files with 26 additions and 26 deletions

View file

@ -2903,23 +2903,23 @@ void InputDeviceHandler::init()
connect(VirtualDesktopManager::self(), &VirtualDesktopManager::currentChanged, this, &InputDeviceHandler::update);
}
bool InputDeviceHandler::setAt(Toplevel *toplevel)
bool InputDeviceHandler::setHover(Toplevel *toplevel)
{
if (m_at.at == toplevel) {
if (m_hover.window == toplevel) {
return false;
}
auto old = m_at.at;
disconnect(m_at.surfaceCreatedConnection);
m_at.surfaceCreatedConnection = QMetaObject::Connection();
auto old = m_hover.window;
disconnect(m_hover.surfaceCreatedConnection);
m_hover.surfaceCreatedConnection = QMetaObject::Connection();
m_at.at = toplevel;
m_hover.window = toplevel;
Q_EMIT atChanged(old, toplevel);
return true;
}
void InputDeviceHandler::setFocus(Toplevel *toplevel)
{
m_focus.focus = toplevel;
m_focus.window = toplevel;
//TODO: call focusUpdate?
}
@ -2939,21 +2939,21 @@ void InputDeviceHandler::setInternalWindow(QWindow *window)
void InputDeviceHandler::updateFocus()
{
auto oldFocus = m_focus.focus;
auto oldFocus = m_focus.window;
if (m_at.at && !m_at.at->surface()) {
if (m_hover.window && !m_hover.window->surface()) {
// The surface has not yet been created (special XWayland case).
// Therefore listen for its creation.
if (!m_at.surfaceCreatedConnection) {
m_at.surfaceCreatedConnection = connect(m_at.at, &Toplevel::surfaceChanged,
if (!m_hover.surfaceCreatedConnection) {
m_hover.surfaceCreatedConnection = connect(m_hover.window, &Toplevel::surfaceChanged,
this, &InputDeviceHandler::update);
}
m_focus.focus = nullptr;
m_focus.window = nullptr;
} else {
m_focus.focus = m_at.at;
m_focus.window = m_hover.window;
}
focusUpdate(oldFocus, m_focus.focus);
focusUpdate(oldFocus, m_focus.window);
}
bool InputDeviceHandler::updateDecoration()
@ -2961,7 +2961,7 @@ bool InputDeviceHandler::updateDecoration()
const auto oldDeco = m_focus.decoration;
m_focus.decoration = nullptr;
auto *ac = qobject_cast<AbstractClient*>(m_at.at);
auto *ac = qobject_cast<AbstractClient*>(m_hover.window);
if (ac && ac->decoratedClient()) {
if (!ac->clientGeometry().contains(position().toPoint())) {
// input device above decoration
@ -3000,7 +3000,7 @@ void InputDeviceHandler::update()
toplevel = input()->findToplevel(position().toPoint());
}
// Always set the toplevel at the position of the input device.
setAt(toplevel);
setHover(toplevel);
if (focusUpdatesBlocked()) {
workspace()->updateFocusMousePosition(position().toPoint());
@ -3021,7 +3021,7 @@ void InputDeviceHandler::update()
} else {
updateInternalWindow(nullptr);
if (m_focus.focus != m_at.at) {
if (m_focus.window != m_hover.window) {
// focus change
updateDecoration();
updateFocus();
@ -3034,14 +3034,14 @@ void InputDeviceHandler::update()
workspace()->updateFocusMousePosition(position().toPoint());
}
Toplevel *InputDeviceHandler::at() const
Toplevel *InputDeviceHandler::hover() const
{
return m_at.at.data();
return m_hover.window.data();
}
Toplevel *InputDeviceHandler::focus() const
{
return m_focus.focus.data();
return m_focus.window.data();
}
Decoration::DecoratedClientImpl *InputDeviceHandler::decoration() const

View file

@ -422,7 +422,7 @@ public:
*
* This will be null if no toplevel is at the position
*/
Toplevel *at() const;
Toplevel *hover() const;
/**
* @brief Toplevel currently having pointer input focus (this might
* be different from the Toplevel at the position of the pointer).
@ -485,18 +485,18 @@ protected:
uint32_t m_lastEventTime = 0;
private:
bool setAt(Toplevel *toplevel);
bool setHover(Toplevel *toplevel);
void updateFocus();
bool updateDecoration();
void updateInternalWindow(QWindow *window);
struct {
QPointer<Toplevel> at;
QPointer<Toplevel> window;
QMetaObject::Connection surfaceCreatedConnection;
} m_at;
} m_hover;
struct {
QPointer<Toplevel> focus;
QPointer<Toplevel> window;
QPointer<Decoration::DecoratedClientImpl> decoration;
QPointer<QWindow> internalWindow;
} m_focus;

View file

@ -601,7 +601,7 @@ void PointerInputRedirection::focusUpdate(Toplevel *focusOld, Toplevel *focusNow
if (internalWindow()) {
// enter internal window
const auto pos = at()->pos();
const auto pos = hover()->pos();
QEnterEvent enterEvent(pos, pos, m_pos);
QCoreApplication::sendEvent(internalWindow(), &enterEvent);
}