This repository has been archived on 2025-12-24. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
yachat/qt-patches/008-win-4.3-QContextMenuEvent correctly handles modifiers.patch

92 lines
5 KiB
Diff
Raw Permalink Normal View History

2025-12-25 01:37:49 +05:00
diff -urN qt-all-opensource-src-4.3.5.orig/src/gui/kernel/qapplication.cpp qt-all-opensource-src-4.3.5/src/gui/kernel/qapplication.cpp
--- qt-all-opensource-src-4.3.5.orig/src/gui/kernel/qapplication.cpp 2008-05-26 13:06:55.000000000 +0400
+++ qt-all-opensource-src-4.3.5/src/gui/kernel/qapplication.cpp 2008-09-04 18:27:38.000000000 +0400
@@ -3342,7 +3342,7 @@
QPoint relpos = context->pos();
bool eventAccepted = context->isAccepted();
while (w) {
- QContextMenuEvent ce(context->reason(), relpos, context->globalPos());
+ QContextMenuEvent ce(context->reason(), relpos, context->globalPos(), context->modifiers());
ce.spont = e->spontaneous();
res = d->notify_helper(w, w == receiver ? context : &ce);
eventAccepted = ((w == receiver) ? context : &ce)->isAccepted();
diff -urN qt-all-opensource-src-4.3.5.orig/src/gui/kernel/qapplication_win.cpp qt-all-opensource-src-4.3.5/src/gui/kernel/qapplication_win.cpp
--- qt-all-opensource-src-4.3.5.orig/src/gui/kernel/qapplication_win.cpp 2008-05-26 13:06:55.000000000 +0400
+++ qt-all-opensource-src-4.3.5/src/gui/kernel/qapplication_win.cpp 2008-09-04 18:29:37.000000000 +0400
@@ -1076,7 +1076,17 @@
SetCursor(cW->cursor().handle());
}
-
+Qt::KeyboardModifiers qt_win_getKeyboardModifiers()
+{
+ Qt::KeyboardModifiers modifiers = Qt::NoModifier;
+ if (GetKeyState(VK_SHIFT) < 0)
+ modifiers |= Qt::ShiftModifier;
+ if (GetKeyState(VK_CONTROL) < 0)
+ modifiers |= Qt::ControlModifier;
+ if (GetKeyState(VK_MENU) < 0)
+ modifiers |= Qt::AltModifier;
+ return modifiers;
+}
/*****************************************************************************
Routines to find a Qt widget from a screen position
@@ -1930,7 +1940,8 @@
}
if (fw && fw->isEnabled()) {
QPoint pos = fw->inputMethodQuery(Qt::ImMicroFocus).toRect().center();
- QContextMenuEvent e(QContextMenuEvent::Keyboard, pos, fw->mapToGlobal(pos));
+ QContextMenuEvent e(QContextMenuEvent::Keyboard, pos, fw->mapToGlobal(pos),
+ qt_win_getKeyboardModifiers());
result = qt_sendSpontaneousEvent(fw, &e);
}
}
@@ -2739,7 +2750,8 @@
} else if (type == QEvent::MouseButtonRelease && button == Qt::RightButton
&& qApp->activePopupWidget() == activePopupWidget) {
// popup still alive and received right-button-release
- QContextMenuEvent e2(QContextMenuEvent::Mouse, pos, globalPos);
+ QContextMenuEvent e2(QContextMenuEvent::Mouse, pos, globalPos,
+ qt_win_getKeyboardModifiers());
bool res2 = QApplication::sendSpontaneousEvent( target, &e2 );
if (!res) // RMB not accepted
res = res2 && e2.isAccepted();
@@ -2783,7 +2795,8 @@
// non client area events are only informational, you cannot "handle" them
res = res && e.isAccepted() && !nonClientAreaEvent;
if (type == QEvent::MouseButtonRelease && button == Qt::RightButton) {
- QContextMenuEvent e2(QContextMenuEvent::Mouse, pos, QPoint(gpos.x,gpos.y));
+ QContextMenuEvent e2(QContextMenuEvent::Mouse, pos, QPoint(gpos.x,gpos.y),
+ qt_win_getKeyboardModifiers());
bool res2 = QApplication::sendSpontaneousEvent(widget, &e2);
if (!res)
res = res2 && e2.isAccepted();
diff -urN qt-all-opensource-src-4.3.5.orig/src/gui/kernel/qevent.cpp qt-all-opensource-src-4.3.5/src/gui/kernel/qevent.cpp
--- qt-all-opensource-src-4.3.5.orig/src/gui/kernel/qevent.cpp 2008-05-26 13:06:56.000000000 +0400
+++ qt-all-opensource-src-4.3.5/src/gui/kernel/qevent.cpp 2008-09-04 18:30:09.000000000 +0400
@@ -1314,6 +1314,11 @@
: QInputEvent(ContextMenu), p(pos), gp(globalPos), reas(reason)
{}
+QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos,
+ Qt::KeyboardModifiers modifiers)
+ : QInputEvent(ContextMenu, modifiers), p(pos), gp(globalPos), reas(reason)
+{}
+
#ifdef QT3_SUPPORT
/*!
Constructs a context menu event with the given \a reason for the
diff -urN qt-all-opensource-src-4.3.5.orig/src/gui/kernel/qevent.h qt-all-opensource-src-4.3.5/src/gui/kernel/qevent.h
--- qt-all-opensource-src-4.3.5.orig/src/gui/kernel/qevent.h 2008-05-26 13:06:56.000000000 +0400
+++ qt-all-opensource-src-4.3.5/src/gui/kernel/qevent.h 2008-09-04 18:30:36.000000000 +0400
@@ -380,6 +380,8 @@
public:
enum Reason { Mouse, Keyboard, Other };
+ QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos,
+ Qt::KeyboardModifiers modifiers);
QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos);
QContextMenuEvent(Reason reason, const QPoint &pos);
~QContextMenuEvent();