Commit c83f0410 authored by Martin Flöser's avatar Martin Flöser

Move startMoveResize() to AbstractClient

The implementation calls a virtual doStartMoveResize() which allows
Client to do it's X11 specific tasks (creating moveResizeWindow, grabbing
input).

The base implementation is no longer virtual.
parent 9e323227
......@@ -1124,9 +1124,9 @@ void AbstractClient::updateHaveResizeEffect()
s_haveResizeEffect = effects && static_cast<EffectsHandlerImpl*>(effects)->provides(Effect::Resize);
}
bool AbstractClient::startMoveResize()
bool AbstractClient::doStartMoveResize()
{
return false;
return true;
}
}
......@@ -698,7 +698,16 @@ protected:
void updateCursor();
void startDelayedMoveResize();
void stopDelayedMoveResize();
virtual bool startMoveResize();
bool startMoveResize();
/**
* Called from @link startMoveResize.
*
* Implementing classes should return @c false if starting move resize should
* get aborted. In that case @link startMoveResize will also return @c false.
*
* Base implementation returns @c true.
**/
virtual bool doStartMoveResize();
void finishMoveResize(bool cancel);
/**
* Leaves the move resize mode.
......
......@@ -468,6 +468,7 @@ protected:
void setGeometryRestore(const QRect &geo) override;
void updateTabGroupStates(TabGroup::States states) override;
void doMove(int x, int y) override;
bool doStartMoveResize() override;
private Q_SLOTS:
void delayedSetShortcut();
......@@ -543,7 +544,6 @@ private:
int checkShadeGeometry(int w, int h);
void getSyncCounter();
void sendSyncRequest();
bool startMoveResize() override;
void leaveMoveResize() override;
void handleMoveResize(int x, int y, int x_root, int y_root);
void handleMoveResize(const QPoint &local, const QPoint &global);
......
......@@ -2605,7 +2605,7 @@ void Client::positionGeometryTip()
}
}
bool Client::startMoveResize()
bool AbstractClient::startMoveResize()
{
assert(!isMoveResize());
assert(QWidget::keyboardGrabber() == NULL);
......@@ -2615,27 +2615,7 @@ bool Client::startMoveResize()
return false; // popups have grab
if (isFullScreen() && (screens()->count() < 2 || !isMovableAcrossScreens()))
return false;
bool has_grab = false;
// This reportedly improves smoothness of the moveresize operation,
// something with Enter/LeaveNotify events, looks like XFree performance problem or something *shrug*
// (http://lists.kde.org/?t=107302193400001&r=1&w=2)
QRect r = workspace()->clientArea(FullArea, this);
m_moveResizeGrabWindow.create(r, XCB_WINDOW_CLASS_INPUT_ONLY, 0, NULL, rootWindow());
m_moveResizeGrabWindow.map();
m_moveResizeGrabWindow.raise();
updateXTime();
const xcb_grab_pointer_cookie_t cookie = xcb_grab_pointer_unchecked(connection(), false, m_moveResizeGrabWindow,
XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_POINTER_MOTION |
XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW,
XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, m_moveResizeGrabWindow, Cursor::x11Cursor(cursor()), xTime());
ScopedCPointer<xcb_grab_pointer_reply_t> pointerGrab(xcb_grab_pointer_reply(connection(), cookie, NULL));
if (!pointerGrab.isNull() && pointerGrab->status == XCB_GRAB_STATUS_SUCCESS) {
has_grab = true;
}
if (grabXKeyboard(frameId()))
has_grab = move_resize_has_keyboard_grab = true;
if (!has_grab) { // at least one grab is necessary in order to be able to finish move/resize
m_moveResizeGrabWindow.reset();
if (!doStartMoveResize()) {
return false;
}
......@@ -2645,7 +2625,7 @@ bool Client::startMoveResize()
const Position mode = moveResizePointerMode();
if (mode != PositionCenter) { // means "isResize()" but moveResizeMode = true is set below
if (maximizeMode() == MaximizeFull) { // partial is cond. reset in finishMoveResize
geom_restore = geometry(); // "restore" to current geometry
setGeometryRestore(geometry()); // "restore" to current geometry
setMaximize(false, false);
}
}
......@@ -2653,7 +2633,7 @@ bool Client::startMoveResize()
if (quickTileMode() != QuickTileNone && mode != PositionCenter) { // Cannot use isResize() yet
// Exit quick tile mode when the user attempts to resize a tiled window
updateQuickTileMode(QuickTileNone); // Do so without restoring original geometry
geom_restore = geometry();
setGeometryRestore(geometry());
emit quickTileModeChanged();
}
......@@ -2666,6 +2646,34 @@ bool Client::startMoveResize()
return true;
}
bool Client::doStartMoveResize()
{
bool has_grab = false;
// This reportedly improves smoothness of the moveresize operation,
// something with Enter/LeaveNotify events, looks like XFree performance problem or something *shrug*
// (http://lists.kde.org/?t=107302193400001&r=1&w=2)
QRect r = workspace()->clientArea(FullArea, this);
m_moveResizeGrabWindow.create(r, XCB_WINDOW_CLASS_INPUT_ONLY, 0, NULL, rootWindow());
m_moveResizeGrabWindow.map();
m_moveResizeGrabWindow.raise();
updateXTime();
const xcb_grab_pointer_cookie_t cookie = xcb_grab_pointer_unchecked(connection(), false, m_moveResizeGrabWindow,
XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_POINTER_MOTION |
XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW,
XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, m_moveResizeGrabWindow, Cursor::x11Cursor(cursor()), xTime());
ScopedCPointer<xcb_grab_pointer_reply_t> pointerGrab(xcb_grab_pointer_reply(connection(), cookie, NULL));
if (!pointerGrab.isNull() && pointerGrab->status == XCB_GRAB_STATUS_SUCCESS) {
has_grab = true;
}
if (grabXKeyboard(frameId()))
has_grab = move_resize_has_keyboard_grab = true;
if (!has_grab) { // at least one grab is necessary in order to be able to finish move/resize
m_moveResizeGrabWindow.reset();
return false;
}
return true;
}
void AbstractClient::finishMoveResize(bool cancel)
{
const bool wasResize = isResize(); // store across leaveMoveResize
......
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