[kdecoration2] Detect double clicks on the decoration title bar

No longer handled by the Decoration.
This commit is contained in:
Martin Gräßlin 2014-11-28 14:50:21 +01:00
parent 0efa9d9c73
commit d1bf38e92c
4 changed files with 20 additions and 16 deletions

View file

@ -519,12 +519,6 @@ void Client::createDecoration(const QRect& oldgeom)
if (m_decoration) {
m_decoration->update();
connect(m_decoration, &KDecoration2::Decoration::shadowChanged, this, &Toplevel::getShadow);
connect(m_decoration, &KDecoration2::Decoration::titleBarDoubleClicked, this,
[this]() {
Workspace::self()->performWindowOperation(this, options->operationTitlebarDblClick());
dontMoveResize();
}
);
connect(m_decoration, &KDecoration2::Decoration::resizeOnlyBordersChanged, this, &Client::updateInputWindow);
connect(m_decoration, &KDecoration2::Decoration::bordersChanged, this,
[this]() {

View file

@ -29,6 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "toplevel.h"
#include "xcbutils.h"
// Qt
#include <QElapsedTimer>
#include <QPixmap>
#include <QWindow>
// X
@ -868,6 +869,7 @@ private:
QScopedPointer<QWindow> m_frameWrapper;
KDecoration2::Decoration *m_decoration;
QPointer<Decoration::DecoratedClientImpl> m_decoratedClient;
QElapsedTimer m_decorationDoubleClickTimer;
int desk;
QStringList activityList;
int m_activityUpdatesBlocked;

View file

@ -50,6 +50,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QApplication>
#include <QDebug>
#include <QStyleHints>
#include <QWhatsThis>
#include <kkeyserver.h>
@ -1232,6 +1233,19 @@ bool Client::processDecorationButtonPress(int button, int /*state*/, int x, int
if (!wantsInput()) // we cannot be active, use it anyway
active = true;
// check whether it is a double click
if (button == XCB_BUTTON_INDEX_1) {
if (m_decorationDoubleClickTimer.isValid() &&
m_decoration->titleBar().contains(x, y) &&
!m_decorationDoubleClickTimer.hasExpired(QGuiApplication::styleHints()->mouseDoubleClickInterval())) {
Workspace::self()->performWindowOperation(this, options->operationTitlebarDblClick());
dontMoveResize();
m_decorationDoubleClickTimer.invalidate();
return false;
}
m_decorationDoubleClickTimer.invalidate();
}
if (button == XCB_BUTTON_INDEX_1)
com = active ? options->commandActiveTitlebar1() : options->commandInactiveTitlebar1();
else if (button == XCB_BUTTON_INDEX_2)
@ -1277,7 +1291,11 @@ bool Client::buttonReleaseEvent(xcb_window_t w, int button, int state, int x, in
x11ToQtMouseButton(button),
x11ToQtMouseButtons(state) & ~x11ToQtMouseButton(button),
x11ToQtKeyboardModifiers(state));
event.setAccepted(false);
QCoreApplication::sendEvent(m_decoration, &event);
if (!event.isAccepted() && m_decoration->titleBar().contains(x, y) && button == XCB_BUTTON_INDEX_1) {
m_decorationDoubleClickTimer.start();
}
}
}
if (w == wrapperId()) {

View file

@ -113,16 +113,6 @@ PreviewClient::PreviewClient(DecoratedClient *c, Decoration *decoration)
emit paletteChanged(m_palette);
}
);
connect(decoration, &Decoration::titleBarDoubleClicked, this,
[this]() {
if (!isMaximizeable()) {
return;
}
const bool maximize = !isMaximized();
setMaximizedHorizontally(maximize);
setMaximizedVertically(maximize);
}
);
auto emitEdgesChanged = [this, c]() {
c->adjacentScreenEdgesChanged(adjacentScreenEdges());
};