[kdecoration2] Detect double clicks on the decoration title bar
No longer handled by the Decoration.
This commit is contained in:
parent
0efa9d9c73
commit
d1bf38e92c
4 changed files with 20 additions and 16 deletions
|
@ -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]() {
|
||||
|
|
2
client.h
2
client.h
|
@ -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;
|
||||
|
|
18
events.cpp
18
events.cpp
|
@ -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()) {
|
||||
|
|
|
@ -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());
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue