Add method to EffectsHandler to define the cursor for an input window

Convenience method to replace XDefineCursor used in the effects.

REVIEW: 109039
This commit is contained in:
Martin Gräßlin 2013-02-19 18:35:23 +01:00
parent be4c76ede1
commit c3423b15e7
6 changed files with 18 additions and 11 deletions

View file

@ -1190,6 +1190,11 @@ void EffectsHandlerImpl::destroyInputWindow(xcb_window_t w)
abort();
}
void EffectsHandlerImpl::defineCursor(xcb_window_t w, Qt::CursorShape shape)
{
Xcb::defineCursor(w, Cursor::x11Cursor(shape));
}
bool EffectsHandlerImpl::checkInputWindowEvent(XEvent* e)
{
if (e->type != ButtonPress && e->type != ButtonRelease && e->type != MotionNotify)

View file

@ -140,6 +140,7 @@ public:
virtual xcb_window_t createInputWindow(Effect* e, int x, int y, int w, int h, const QCursor& cursor);
using EffectsHandler::createInputWindow;
virtual void destroyInputWindow(xcb_window_t w);
virtual void defineCursor(xcb_window_t w, Qt::CursorShape shape);
virtual bool checkInputWindowEvent(XEvent* e);
virtual void checkInputWindowStacking();

View file

@ -1982,10 +1982,10 @@ void CubeEffect::slotMouseChanged(const QPoint& pos, const QPoint& oldpos, Qt::M
}
}
if (!oldbuttons.testFlag(Qt::LeftButton) && buttons.testFlag(Qt::LeftButton)) {
XDefineCursor(display(), input, QCursor(Qt::ClosedHandCursor).handle());
effects->defineCursor(input, Qt::ClosedHandCursor);
}
if (oldbuttons.testFlag(Qt::LeftButton) && !buttons.testFlag(Qt::LeftButton)) {
XDefineCursor(display(), input, QCursor(Qt::OpenHandCursor).handle());
effects->defineCursor(input, Qt::OpenHandCursor);
if (closeOnMouseRelease)
setActive(false);
}

View file

@ -521,7 +521,7 @@ void DesktopGridEffect::windowInputMouseEvent(Window, QEvent* e)
}
m_proxy->calculateWindowTransformations(manager.managedWindows(), windowMove->screen(), manager);
}
XDefineCursor(display(), input, QCursor(Qt::ClosedHandCursor).handle());
effects->defineCursor(input, Qt::ClosedHandCursor);
}
wasWindowMove = true;
if (windowMove->isMovable() && !isUsingPresentWindows()) {
@ -539,7 +539,7 @@ void DesktopGridEffect::windowInputMouseEvent(Window, QEvent* e)
} else if ((me->buttons() & Qt::LeftButton) && !wasDesktopMove &&
(me->pos() - dragStartPos).manhattanLength() > KGlobalSettings::dndEventDelay()) {
wasDesktopMove = true;
XDefineCursor(display(), input, QCursor(Qt::ClosedHandCursor).handle());
effects->defineCursor(input, Qt::ClosedHandCursor);
}
if (d != highlightedDesktop) { // Highlight desktop
if ((me->buttons() & Qt::LeftButton) && isValidMove && !wasWindowMove && d <= effects->numberOfDesktops()) {
@ -673,9 +673,9 @@ void DesktopGridEffect::windowInputMouseEvent(Window, QEvent* e)
}
effects->setElevatedWindow(windowMove, false);
windowMove = NULL;
XDefineCursor(display(), input, QCursor(Qt::PointingHandCursor).handle());
effects->defineCursor(input, Qt::PointingHandCursor);
} else if (wasDesktopMove)
XDefineCursor(display(), input, QCursor(Qt::PointingHandCursor).handle());
effects->defineCursor(input, Qt::PointingHandCursor);
wasWindowMove = false;
wasDesktopMove = false;
}

View file

@ -559,7 +559,7 @@ void PresentWindowsEffect::windowInputMouseEvent(Window w, QEvent *e)
m_highlightedDropTarget = NULL;
}
effects->addRepaintFull();
XDefineCursor(display(), m_input, QCursor(Qt::PointingHandCursor).handle());
effects->defineCursor(m_input, Qt::PointingHandCursor);
return;
}
if (hovering) {
@ -598,7 +598,7 @@ void PresentWindowsEffect::windowInputMouseEvent(Window w, QEvent *e)
m_highlightedDropTarget->setIcon(icon.pixmap(QSize(128, 128), QIcon::Normal));
m_highlightedDropTarget = NULL;
}
XDefineCursor(display(), m_input, QCursor(Qt::PointingHandCursor).handle());
effects->defineCursor(m_input, Qt::PointingHandCursor);
} else if (e->type() == QEvent::MouseButtonPress && me->button() == Qt::LeftButton && hovering && m_dragToClose) {
m_dragStart = me->pos();
m_dragWindow = m_highlightedWindow;
@ -610,7 +610,7 @@ void PresentWindowsEffect::windowInputMouseEvent(Window w, QEvent *e)
if (e->type() == QEvent::MouseMove && m_dragWindow) {
if ((me->pos() - m_dragStart).manhattanLength() > KGlobalSettings::dndEventDelay() && !m_dragInProgress) {
m_dragInProgress = true;
XDefineCursor(display(), m_input, QCursor(Qt::ForbiddenCursor).handle());
effects->defineCursor(m_input, Qt::ForbiddenCursor);
}
if (!m_dragInProgress) {
return;
@ -628,13 +628,13 @@ void PresentWindowsEffect::windowInputMouseEvent(Window w, QEvent *e)
KIcon icon("user-trash");
effects->addRepaint(m_highlightedDropTarget->geometry());
m_highlightedDropTarget->setIcon(icon.pixmap(QSize(128, 128), QIcon::Active));
XDefineCursor(display(), m_input, QCursor(Qt::DragMoveCursor).handle());
effects->defineCursor(m_input, Qt::DragMoveCursor);
} else if (!target && m_highlightedDropTarget) {
KIcon icon("user-trash");
effects->addRepaint(m_highlightedDropTarget->geometry());
m_highlightedDropTarget->setIcon(icon.pixmap(QSize(128, 128), QIcon::Normal));
m_highlightedDropTarget = NULL;
XDefineCursor(display(), m_input, QCursor(Qt::ForbiddenCursor).handle());
effects->defineCursor(m_input, Qt::ForbiddenCursor);
}
}
}

View file

@ -638,6 +638,7 @@ public:
xcb_window_t createInputWindow(Effect* e, const QRect& r, const QCursor& cursor);
virtual xcb_window_t createFullScreenInputWindow(Effect* e, const QCursor& cursor);
virtual void destroyInputWindow(xcb_window_t w) = 0;
virtual void defineCursor(xcb_window_t w, Qt::CursorShape shape) = 0;
virtual QPoint cursorPos() const = 0;
virtual bool grabKeyboard(Effect* effect) = 0;
virtual void ungrabKeyboard() = 0;