Commit 8ee55029 authored by Martin Flöser's avatar Martin Flöser

Move enterNotify handling to AbstractClient

General handling for mouse driven focus and auto raise should and can
be shared between Client and ShellClient. Thus the code is moved to
AbstractClient and invoked from Client::enterNotifyEvent.
parent 6b06779a
......@@ -30,6 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#endif
#include "screenedge.h"
#include "tabgroup.h"
#include "useractions.h"
#include "workspace.h"
#include "wayland_server.h"
......@@ -1498,4 +1499,28 @@ void AbstractClient::setDecoratedClient(QPointer< Decoration::DecoratedClientImp
m_decoration.client = client;
}
void AbstractClient::enterEvent(const QPoint &globalPos)
{
// TODO: shade hover
if (options->focusPolicy() == Options::ClickToFocus || workspace()->userActionsMenu()->isShown())
return;
if (options->isAutoRaise() && !isDesktop() &&
!isDock() && workspace()->focusChangeEnabled() &&
globalPos != workspace()->focusMousePosition() &&
workspace()->topClientOnDesktop(VirtualDesktopManager::self()->current(),
options->isSeparateScreenFocus() ? screen() : -1) != this) {
startAutoRaise();
}
if (isDesktop() || isDock())
return;
// for FocusFollowsMouse, change focus only if the mouse has actually been moved, not if the focus
// change came because of window changes (e.g. closing a window) - #92290
if (options->focusPolicy() != Options::FocusFollowsMouse
|| globalPos != workspace()->focusMousePosition()) {
workspace()->requestDelayFocus(this);
}
}
}
......@@ -406,6 +406,8 @@ public:
void endMoveResize();
void keyPressEvent(uint key_code);
void enterEvent(const QPoint &globalPos);
/**
* These values represent positions inside an area
*/
......
......@@ -948,26 +948,7 @@ void Client::enterNotifyEvent(xcb_enter_notify_event_t *e)
}
#undef MOUSE_DRIVEN_FOCUS
if (options->focusPolicy() == Options::ClickToFocus || workspace()->userActionsMenu()->isShown())
return;
QPoint currentPos(e->root_x, e->root_y);
if (options->isAutoRaise() && !isDesktop() &&
!isDock() && workspace()->focusChangeEnabled() &&
currentPos != workspace()->focusMousePosition() &&
workspace()->topClientOnDesktop(VirtualDesktopManager::self()->current(),
options->isSeparateScreenFocus() ? screen() : -1) != this) {
startAutoRaise();
}
if (isDesktop() || isDock())
return;
// for FocusFollowsMouse, change focus only if the mouse has actually been moved, not if the focus
// change came because of window changes (e.g. closing a window) - #92290
if (options->focusPolicy() != Options::FocusFollowsMouse
|| currentPos != workspace()->focusMousePosition()) {
workspace()->requestDelayFocus(this);
}
enterEvent(QPoint(e->root_x, e->root_y));
return;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment